Student Assignment

Reply

Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Student Assignment

 
0
  #11
Jul 1st, 2009
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!

  1.  
  2. public double getGrade( GradeType myGrade )
  3. {
  4. return 4.0 - myGrade; // { 4...0} <--- {0...4}
  5. }

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
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: lovley is an unknown quantity at this point 
Solved Threads: 0
lovley lovley is offline Offline
Newbie Poster

Re: Student Assignment

 
0
  #12
Jul 1st, 2009
ok so now the error is this:

C:\Users\Ash Ketchum\Documents\New Folder\Student.java:39: class, interface, or enum expected
}
^
1 error

Tool completed with exit code 1
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Student Assignment

 
0
  #13
Jul 1st, 2009
count your braces!
For every { there is a }.
Print your code off. Write a little number next to each one! Add 1 for each { and -1 for each }
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: lovley is an unknown quantity at this point 
Solved Threads: 0
lovley lovley is offline Offline
Newbie Poster

Re: Student Assignment

 
0
  #14
Jul 2nd, 2009
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........
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Student Assignment

 
0
  #15
Jul 2nd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: lovley is an unknown quantity at this point 
Solved Threads: 0
lovley lovley is offline Offline
Newbie Poster

Re: Student Assignment

 
0
  #16
Jul 2nd, 2009
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

  1. public double calculateGPA(double effectiveGPA)
  2. {
  3.  
  4. double grade = 0;
  5.  
  6. for (int i = 0; i<gradeList.size(); i++)
  7.  
  8. {
  9.  
  10. grade+= gradeList.get(i);
  11.  
  12. }
  13.  
  14. return grade/gradeList.size();
  15.  
  16. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,765
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 493
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Student Assignment

 
0
  #17
Jul 2nd, 2009
Originally Posted by lovley View Post
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

  1. public double calculateGPA(double effectiveGPA)
  2. {
  3.  
  4. double grade = 0;
  5.  
  6. for (int i = 0; i<gradeList.size(); i++)
  7.  
  8. {
  9.  
  10. grade+= gradeList.get(i);
  11.  
  12. }
  13.  
  14. return grade/gradeList.size();
  15.  
  16. }

This function is the same as this:

  1. public double calculateGPA()
  2. {
  3.  
  4. double grade = 0;
  5.  
  6. for (int i = 0; i<gradeList.size(); i++)
  7.  
  8. {
  9.  
  10. grade+= gradeList.get(i);
  11.  
  12. }
  13.  
  14. return grade/gradeList.size();
  15.  
  16. }

You pass the variable effectiveGPA , but don't use it, so you might as well not pass it.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: lovley is an unknown quantity at this point 
Solved Threads: 0
lovley lovley is offline Offline
Newbie Poster

Re: Student Assignment

 
0
  #18
Jul 2nd, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,765
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 493
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Student Assignment

 
0
  #19
Jul 2nd, 2009
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:

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.

  1. public double calculateGPA ()
  2. {
  3. effectiveGPA = 0.0;
  4. return effectiveGPA;
  5. }

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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC