Re: Question on a method?
Please explain your problem or ask a question.
Show the program's output and explain what is wrong with it and show what it should be.
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
Re: Question on a method?
Quote:
Originally Posted by
Norm
Please explain your problem or ask a question.
Show the program's output and explain what is wrong with it and show what it should be.
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
This is the output :12345
Cameron Cochran
0.0
null null 0.0 . It prints out null for the gpa, courseID , lettergrade and numbergrade variables. Im trying to figure out how to get the calculategpa and updatecourse methods to work.
Re: Question on a method?
Quote:
It prints out null for the gpa, courseID , lettergrade and numbergrade variables.
I see 2 null values that are being printed, but your there are 4 variables in the list of variables you gave???
Look at the code and see why those variables do not have valid non-null values. Where does the code assign them values?
Re: Question on a method?
Quote:
Originally Posted by
Norm
I see 2 null values that are being printed, but your there are 4 variables in the list of variables you gave???
Look at the code and see why those variables do not have valid non-null values. Where does the code assign them values?
Thanks and I have one more question on the calcuategpa method. Would I use a while loop to go through the array to make the calculation, or would I use a different way?
Re: Question on a method?
If the data is in an array you'd use a for loop. If the data is in another kind of collection you'd probably use a while loop.
Re: Question on a method?
Well in each one of your methods involving your courses, you are resetting it to a null value, so you never actually add any data into it.
Re: Question on a method?
Quote:
Originally Posted by
Parranoia
Well in each one of your methods involving your courses, you are resetting it to a null value, so you never actually add any data into it.
When I test using the toString method it returns that issue . How would I call the information from the other class into this class?
Re: Question on a method?
Where is the information that you want to access? What variable in what class?
In what method in what class do you want to access that information?
One way is for the class with the information to have a method that can be called that will return the info.