StudentGradeswhich stores information about a student's grades in a class. Specifically, an object stores:
toStringprints the state of the object in the following format:
Ann Smith PS: 5 7 9 10 5 Midterm: 73 Final: 67
setFinalfor setting the grades for the midterm and the final. If the value of the parameter is not within the range 0 to 100, an error message is displayed and the value is not set.
setProbSetGradewhich sets the grade for a specific problem set (i.e. it takes two parameters: the number of the problem set and the grade). As the in previous two methods, an error message is displayed for an illegal value and no value is set. Note that the problem set number could be illegal as well.
getName, getMidterm, getFinal, and
getProbSetGradeto get the values of the name, the midterm grade, the final grade, and the grade for a particular problem set.
getProbSetAveragereturns the average of the problem sets (what type does it return?)
getTotalreturns the total numerical score. The midterm is 20% of the grade, the problem sets and the final are 40% each.
getLetterreturns the student's letter grade for the class as a character according to the following table:
|Numeric grade||Letter grade|
passedreturns true if the student passed the course, false if he/she failed.
Write the test class
StudentGradesTest. Here is what you
need to do:
passed. Print out the names of students who failed the course. If there are no such students, print out "Everyone passed".
Don't worry about minor problems with formatting. It's OK if your output looks like this:
Ann Smith PS: 8 9 7 5 9 Midterm: 88 Final: 52 Brian Peterson PS: 6 7 9 8 5 Midterm: 74 Final: 90 Carol Matthews PS: 6 6 8 7 7 Midterm: 86 Final: 58 Darrel Green PS: 5 10 6 8 5 Midterm: 69 Final: 55 Ellen Lee PS: 5 9 6 5 9 Midterm: 56 Final: 71 Invalid grade value 12 Invalid problem set number 5 Invalid grade value 102 The average on the 3rd problem set is 7.2 Invalid problem set number 6 The grade of Ann Smith on problem set 6 is -1 Ann Smith has the highest problem set average 7.6 0 students have a perfect exam score Ann Smith 68.8 D Brian Peterson 78.8 C Carol Matthews 67.6 D Darrel Green 63.0 D Ellen Lee 66.8 D Everyone passed
Ann Smith 72.8 C Brian Peterson 87.8 B Carol Matthews 66.80000000000001 D Darrel Green 75.2 C Ellen Lee 64.0 D
This assignment is quite involved. Make sure to start early. If you have questions, please ask! The best way to do it is to e-mail the class list. You are also encouraged to answer each other's questions. However, please do not send your code to the class list.
The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.