| | |
Student Assignment
![]() |
I had said before you don't need floats (or doubles) until you are FINALLY done and calculating the final GPA.
But you keep using it in the step by step calcuations so fine!
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.
But you keep using it in the step by step calcuations so fine!
Java Syntax (Toggle Plain Text)
public double getGrade( GradeType myGrade ) { return 4.0 - myGrade; // { 4...0} <--- {0...4} }
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
•
•
Join Date: Jul 2009
Posts: 8
Reputation:
Solved Threads: 0
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........
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........
•
•
Join Date: Jul 2009
Posts: 8
Reputation:
Solved Threads: 0
ok so basically you're saying now I need to do the calculateGPA() method right..... I hope so because that's what I did next so for that I did this
JAVA Syntax (Toggle Plain Text)
public double calculateGPA(double effectiveGPA) { double grade = 0; for (int i = 0; i<gradeList.size(); i++) { grade+= gradeList.get(i); } return grade/gradeList.size(); }
•
•
Join Date: Jan 2008
Posts: 3,765
Reputation:
Solved Threads: 493
•
•
•
•
ok so basically you're saying now I need to do the calculateGPA() method right..... I hope so because that's what I did next so for that I did this
JAVA Syntax (Toggle Plain Text)
public double calculateGPA(double effectiveGPA) { double grade = 0; for (int i = 0; i<gradeList.size(); i++) { grade+= gradeList.get(i); } return grade/gradeList.size(); }
This function is the same as this:
JAVA Syntax (Toggle Plain Text)
public double calculateGPA() { double grade = 0; for (int i = 0; i<gradeList.size(); i++) { grade+= gradeList.get(i); } return grade/gradeList.size(); }
You pass the variable
effectiveGPA , but don't use it, so you might as well not pass it. •
•
Join Date: Jan 2008
Posts: 3,765
Reputation:
Solved Threads: 493
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:
calculateGPA () takes no arguments. It returns a double. It stores its result in effectiveGPA. You should therefore not have a variable called
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.
Read the spec carefully:
•
•
•
•
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.
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.
Java Syntax (Toggle Plain Text)
public double calculateGPA () { effectiveGPA = 0.0; return effectiveGPA; }
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.
![]() |
Similar Threads
- program that will input a number and display it in words (C)
- C++ meters to yards. (C++)
- Airline Reservation System (ColdFusion)
- Grade Calculator HELP! (VB.NET)
- Standard Code Indentation (C++)
- hi.to develop a software treasure hunting(game) (Computer Science)
- "Input past end of File" error #62 (Legacy and Other Languages)
- Help with assignment (C++)
- problem about the codding (C)
Other Threads in the Java Forum
- Previous Thread: Big errors i got plz help me out illegal type of expression type,
- Next Thread: What is the Use of Inner classes
| Thread Tools | Search this Thread |
911 addball addressbook android api applet application apps array automation awt binary bluetooth businessintelligence busy_handler(null) button card class client code collision component constructor crashcourse css csv database draw eclipse ee error eventlistener exception fractal free game gis givemetehcodez graphics gui html ide image integration j2me japplet java javaarraylist javadoc javafx javamicroeditionuseofmotionsensor javaprojects jni jpanel jtree julia jvm linux loan map method migrate mobile netbeans objects oracle oriented phone physics plazmic problem program programming project projects radio recursion replaydirector reporting scanner se server service set sharepoint smart sms software sortedmaps sql swing test textfield threads tree trolltech ubuntu unlimited utility windows






