CSC 132 Fall 2000
Homework 5
Due: 9 a.m., Thursday 19 October 2000.
30 points
"Grading Objectively"
This is just an exercise in working with iterators and Objects. You will need files IterLinkSeq.java and Grades.java from the eccentric download folder for Homework 5. NOTE: This IterLinkSeq.java is the same class from Lab 5, except it has two additional add() methods for floats and chars, and will not be posted until after our October 12 lab session.
The program Grades.java reads in a series of grades and stores them in a sequenced collection of Objects called grades. Each grade can be one of the following types:
Letter grades are stored as Character objects, numeric grades are stored as Float objects, and descriptive grades are stored as String objects. Any 'grade' that is not numeric or a single character is stored as a String. The input may contain invalid grades; these will still be stored in the grades sequence. Input letter and descriptive grades must match the ones given above exactly, including spelling and case. If the match is not exact, they are considered invalid.
After reading in the grades, the program calls the showGrades() method to show all the grades. It then calls the describeGrades() method, which calculates and outputs the Grade Point Average and classification of input values, as shown in the example below. The output must be produced in the same format as this example. Note that the GPA calculation includes all valid grades, not just the numeric ones, and ignores any invalid grades. GPA is the average of all valid grades. When I grade your program I will use different data.
Your assignment is to implement the showGrades() and describeGrades() methods in Grades.java. I have provided you a small utility method called showObject() that should be called by showGrades() to output a given value from the sequence -- it will output single quotes (') around a character and double quotes (") around a string.
When finished, submit the modified Grades.java file to your eccentric upload folder. Do not make any changes outside of the two methods you are assigned to write. Do not change or submit IterLinkSeq.java. Comment your code but javadoc-style comments not needed.
Point breakdown: 4 points documentation, 4 points design and 22 points correct and correctly formatted results.
Example use of this program:
c:\132\hw5>java Grades A 1.2 fair 347.33 C .25 r kersplat ^Z [press Ctrl-Z; on Linux systems press Ctrl-D] Grades = <'A', 1.2, "fair", 347.33, 'C', 0.25, 'r', "kersplat"> GPA = 1.89 2 numeric grade(s) 2 letter grade(s) 1 descriptive grade(s) 3 invalid grade(s)
You can also use I/O redirection. If you create a file called gdata that contains the following lines,
A 1.2 fair 347.33 C .25 r kersplat
you can run your program like this:
c:\132\hw5>java Grades < gdata Grades = <'A', 1.2, "fair", 347.33, 'C', 0.25, 'r', "kersplat"> GPA = 1.89 2 numeric grade(s) 2 letter grade(s) 1 descriptive grade(s) 3 invalid grade(s)
The "< gdata" says to get the input from file grades instead of the standard input source (normally the keyboard). You don't do anything to the program to get this capability; it is provided by the operating system. I will use this method to grade your program.
[ Assignments | CSC 132 | Peter Sanderson | Computer Science | SMSU ]
Last reviewed: 11 October 2000
Peter Sanderson (
PeteSanderson@smsu.edu )