Forums Forums - Off Topic Forum FUN




Go Back   Forums Forums - Off Topic Forum FUN > Off Topic Forums > Computers, Cell Phones & Electronics Forum

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-30-2018, 09:29 AM
bczoom bczoom is offline
Super Moderator

 
Join Date: Sep 2005
Posts: 16,605
Thanks: 1,695
Thanked 1,973 Times in 917 Posts
bczoom will become famous soon enoughbczoom will become famous soon enough
Style: T66
Default Any Java programmers out there?

Need help with something as I don't know Java. (I'm an old COBOL programmer). Any/all help greatly appreciated.

Trying to compute an average GPA.
My pasting doesn't show indentations.

Here's the code:
public class averageGPA
{
double gpa;
//double sum;

public averageGPA(double a) //order of info
{
gpa = a;

}


public averageGPA gpa1 = new averageGPA(2.9);

public averageGPA gpa2 = new averageGPA(4.0);

public averageGPA gpa3 = new averageGPA(3.9);

public averageGPA gpa4 = new averageGPA(3.0);

public double averageGPA(double gpa)
{
double sum;
sum=gpa1+gpa2+gpa3+gpa4; //GPA is added

int totalStudents = 4; //total students

double averageGPA = sum/totalStudents; //divdie GPA by the number of students
return averageGPA; //return average to display
}

}


It doesn't like the line in red.
Returned error is
"bad operand types for binary operator '+'.
first type: averageGPA
second type: averageGPA

Any ideas? Looks like a storage definition error to me but I don't know Java.
__________________
If you didn't hear it with your own ears or see it with your own eyes, don't invent it with your small mind and share it with your big mouth.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Homeland Security warns to disable Java amid zero-day flaw muleman Computers, Cell Phones & Electronics Forum 0 01-11-2013 05:44 PM
Update Java or delete it to fight malware muleman Computers, Cell Phones & Electronics Forum 1 07-26-2012 08:11 PM
Any programmers on here? tsaw Computers, Cell Phones & Electronics Forum 28 02-07-2011 09:58 PM
Java Jab pirate_girl Junkman's Corner 5 12-12-2008 11:22 PM
Above All Else, Save That Java pirate_girl Open Forum 2 03-29-2008 02:43 AM





All times are GMT -4. The time now is 03:12 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002 - 2018 www.ForumsForums.com