Note That I have a return to return the value passed into the function! You don't.
Also you have that dangling brace before the return! It's in the wrong place!
I also pass a 'GradeType' enum into the function for processing.
Last edited by wildgoose; Jul 1st, 2009 at 7:49 pm. Reason: tags
I totally had a bracket at the very very bottom of the page lol....
anyways ok moving on.... so now I have to code the subclasses
since this method is already calculating the average do I just need to call it in the BachelorStudent?
And how would I go about adding the * 0.98 in the MasterStudent?
And yes I am sorry I feel extra lost if I don't put in the floaters and have the time I forget to put them back in and in the correct way but if it really bothers you I can try to leave them out........
You're only retrieving the converted grade. You need to sum the value with result in a bucket, and increment the grade item tally. When done then do your division.
Ohh... since my assignment said that the method calculateGPA() should returns a double and store it in the effectiveGPA variable I thought that is why I was doing that....
so would I put that in the () in the return line?
effectiveGPA is a class/global variable. Don't pass it to a function. Copy and paste the ENTIRE program and post it here. Be extra careful to copy the entire thing, including all brackets, and mention all compiling errors.
Read the spec carefully:
Quote ...
Student has two child classes BachelorStudent and MasterStudent. Both classes should have the attribute effectiveGPA:double as well as the method calculateGPA() that returns a double and stores it in the effectiveGPA variable.
For the bachelor class, the method should take all the grades in the gradeList arraylist and average them out (Standard grades, A=4, B=3, C=2, D=1, F=0). For the masters class, the method does the same and then multiplies the result by 0.98.
calculateGPA () takes no arguments. It returns a double. It stores its result in effectiveGPA. You should therefore not have a variable called grade in your function. It should be effectiveGPA .
This should all be in the CHILD classes BachelorStudent and MasterStudent, not the parent class Student. Just make a dummy function in Student.
This function will NEVER be executed, but it still should be there in Student. The functions that will be executed will be in MasterStudent and BachelorStudent, which extend Student. If you haven't created MasterStudent and BachelorStudent yet, do so. You should also write some simple constructors now, as well as a very simple driver program.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.