Student Assignment

Reply

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

Student Assignment

 
0
  #1
Jul 1st, 2009
Hey you guys, I am finishing my last two assignments in my class and I am having trouble because as you will see, the directions are not as they appear. My class is online so I don't have anyone I can rack my brain to or with and did I mention both my teacher and teacher assistants are out of the country lol.....so maybe you guys will be able to help. Here is the assignment:


Create a Parent class called Student. The Student class shall have attributes nametring (a variable name which is of type String), id:int, classList:ArrayList, gradeList:ArrayList and gpa:double.
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.

Write a test driver class to create a bachelor student and a master student. Assign 4 grades in their gradelist variable for each - you can either hardcode this or use input from the screen - your choice.

Once done, calculate and print their GPAs along with their Name and ID and designation (Bachelors or Masters student). Also list out any grades for them that are A and F - do this by using the iteration functionality built in to go through each element in the arraylist and check to see if it is A or F, if so, print it.
Also, in output, first print your name, assignment number, and current date in at least two different format. Not hard coded dates, but current day of the day it is executing.

Attack this assignment one small piece at a time.
First - create the classess.
Second - write the methods for the subclasses
Test out the methods by assigning grades and seeing if they work
Third - study the ArrayList structure to see how iteration through it works.
Write a simple iterator through a test arraylist to see if you can seek out a given value.
Read GregorailCalander class in JAVA API, write simple method which prints current date in two different formats.
After you've nailed all this, put all the pieces together.

Have Fun

So so far I have created the parent and child classes and now I am stuck on how to code the calculateGPA() method.... I know that some how I will have to convert the letter grades so that it will know what letter equals what number. I have also declared the attributes so tell me if they look right. Thank you in advance for your help!

public class Student
{
private String string;
private int id;
private String[] classList;
private double gpa;
private double[] gradeList;
private double effectiveGPA;

public double calculateGPA()
{
}
}

public class BachelorStudent extends Student
{
}

public class MasterStudent extends Student
{
}
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
  #2
Jul 1st, 2009
Grade conversion should be easy.
iteration
enumeration
So each enumeration A through F you can assign to to standard scoring levels?
F=0, D=1, C=2, B=3, A=4

And GPA is merely the average.
@sum( 0...N-1) / N

But you need to fill in all your class requirements first, take a pass at writing your code then we can help.
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
  #3
Jul 1st, 2009
ok so I am going to try to enumerate the grades with the Student class here is what I put:
  1. public class Student
  2. {
  3. private String string;
  4. private int id;
  5. private String[] classList;
  6. private double gpa;
  7. private double[] gradeList;
  8. private double effectiveGPA;
  9.  
  10. public enum GradeType
  11. {
  12. A
  13. B
  14. C
  15. D
  16. F
  17. }
  18.  
  19. public static double getGrade(GradeType gt)
  20. {
  21. double grade = 4;
  22. if (gt == GradeType.A)
  23. else if (gt == GradeType.B)
  24. grade = 3;
  25. else if(gt == GradeType.C)
  26. grade = 2;
  27. else if(gt == GradeType.D)
  28. grade = 1;
  29. else if(gt == GradeType.F)
  30. grade = 0;
  31. return grade;
  32. }
  33.  
  34.  
  35. public double calculateGPA()
  36. {
  37. }
  38. }
Last edited by Tekmaven; Jul 1st, 2009 at 6:34 pm. Reason: Code Tags
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
  #4
Jul 1st, 2009
If you're going to use an order letter enum...
public enum GradeType { A, B, C, D, F };
then no need for that case statement comparitor!

nGrade = 4 - myGradeType; { 4...0} <--- {0...4}

Just use a simple function to do the conversion!
Keep as integer. Summation as integer. But convert to float for the division for the averaging!
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
  #5
Jul 1st, 2009
so is this what it should look like so far?

  1. public class Student
  2. {
  3. private String string;
  4. private int id;
  5. private String[] classList;
  6. private double gpa;
  7. private double[] gradeList;
  8. private double effectiveGPA;
  9.  
  10. public enum GradeType { A, B, C, D, F };
  11.  
  12. public double getGrade()
  13. {
  14. nGrade = 4 - myGradeType; { 4...0} <--- {0...4}
  15. }
Last edited by Tekmaven; Jul 1st, 2009 at 7:45 pm. Reason: Code Tags
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
  #6
Jul 1st, 2009
No, I'm a bit rusty with my Java...
  1. public int getGrade( GradeType myGrade )
  2. {
  3. return 4 - myGrade; // { 4...0} <--- {0...4}
  4. }
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
  #7
Jul 1st, 2009
it's ok, you're helping me a lot more than my teachers lol
I just need someone to help me and break it down step by step so thank you so much for taking the time to help

ok so this is what I have so far and this is the error I am recieving.... any idea?
  1. public class Student
  2. {
  3. private String string;
  4. private int id;
  5. private String[] classList;
  6. private double gpa;
  7. private double[] gradeList;
  8. private double effectiveGPA;
  9. private double myGradeType;
  10. private double nGrade;
  11.  
  12. public enum GradeType { A, B, C, D, F };
  13.  
  14. public double getGrade()
  15. {
  16. nGrade = 4 - myGradeType; // { 4...0} <--- {0...4}
  17. }
  18. }
C:\Users\Ash Ketchum\Documents\New Folder\Student.java:17: missing return statement
}
^
1 error

Tool completed with exit code 1
Last edited by Tekmaven; Jul 1st, 2009 at 7:54 pm. Reason: Code Tags
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
  #8
Jul 1st, 2009
Of course
public integer getGrade( GradeType myGrade )
{
    return  4 - myGrade; // { 4...0} <--- {0...4}
}
}
One too many braces!

And you weren't passing in an argument or returning one!
Last edited by wildgoose; Jul 1st, 2009 at 7:39 pm. Reason: code fix
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
  #9
Jul 1st, 2009
I kept twiddling that post.
here's the entire thing
  1. public integer getGrade( GradeType myGrade )
  2. {
  3. return 4 - myGrade; // { 4...0} <--- {0...4}
  4. }
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
  #10
Jul 1st, 2009
Originally Posted by lovley View Post
it's ok, you're helping me a lot more than my teachers lol
I just need someone to help me and break it down step by step so thank you so much for taking the time to help

ok so this is what I have so far and this is the error I am recieving.... any idea?

public class Student
{
private String string;
private int id;
private String[] classList;
private double gpa;
private double[] gradeList;
private double effectiveGPA;
private double myGradeType;
private double nGrade;

public enum GradeType { A, B, C, D, F };

public double getGrade()
{
nGrade = 4 - myGradeType; // { 4...0} <--- {0...4}
}
}

C:\Users\Ash Ketchum\Documents\New Folder\Student.java:17: missing return statement
}
^
1 error

Tool completed with exit code 1

Code tags:


[code=JAVA]
// paste code here
[/code]


It's impossible to read otherwise.

  1. public class Student
  2. {
  3. private String string;
  4. private int id;
  5. private String[] classList;
  6. private double gpa;
  7. private double[] gradeList;
  8. private double effectiveGPA;
  9. private double myGradeType;
  10. private double nGrade;
  11.  
  12. public enum GradeType { A, B, C, D, F };
  13.  
  14. public double getGrade()
  15. {
  16. nGrade = 4 - myGradeType; // { 4...0} <--- {0...4}
  17. }
  18. }
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