In lectures, we explored an application involving a massive collection of UFO sightings. The UFOsighting class stored information about a single sighting and provided methods for accessing that information. The UFOlookup class read in the UFO sighting data from a file, constructed an ArrayList of UFOsighting
objects, and then provided methods for selectively looking up sightings based on location or date. For this assignment, you will develop similar classes that store and process quiz data.
Consider a course in which quizzes may be administered on any given day, and the number of points in each quiz can vary. Furthermore, suppose the instructor is extremely forgiving and allows students to retake quizzes as many times as they like. For a given day, only the last quiz grade recorded will count. In addition, the lowest quiz grade (i.e., the quiz with lowest percentage) is dropped. Quiz grades for a given student are stored in a file, with each line specifying the quiz date, points earned and possible points for a single quiz. For example:
2017/03/10 3 5 2017/03/12 0 8 2017/03/12 6 8 2017/03/17 4 12 2017/03/19 2 4 2017/03/17 8 12
This data shows that four quizzes were taken, with the quizzes on 3/12 and 3/17 being taken twice (and so the first scores, 0/8 and 4/12, are discarded). The lowest remaining quiz grade is 2/4, so the overall quiz grade for this student would be (3+6+8)/(5+8+12) = 17/25 = 68.0.
The Quiz class has been provided for you, which stores the basic information about a quiz. You are to make the following additions to the class:
getPercentage
method, which calculates the percentage score for the quiz. The returned value should be rounded to the nearest tenth, so a quiz with 2 out of 3 points would result in a percentage of 66.7.
toString
method, which returns a String representation of the quiz. The returned String should consist of the data, the points earned and possible points, and the quiz percentage, in the following format:
2017/03/10: earned 3 out of 5 points (60.0%)
Implement the QuizList class, whose javadoc page is provided. This class will be similar to the UFOlookup
class in that it reads and stores data from a file and provides methods for accessing that data. Note the following:
UFOlookup
.Quiz
object that has the lowest percentage. If there is a tie for the lowest grade, a quiz with the most points should be selected. For example, if there is a tie between 2/4 and 5/10, the 5/10 quiz should be selected as the lowest. If this method is called with no quizzes stored, it should simply return null
.2017/03/10: earned 3 out of 5 (60.0%) 2017/03/12: earned 6 out of 8 (75.0%) 2017/03/17: earned 8 out of 12 (66.7%) 2017/03/19: earned 2 out of 4 (50.0%) overall percentage = 68.0
For extra credit: Ensure that the quizzes are displayed in chronological order, regardless of the order in which the data appears in the file.
Be sure to include javadoc comments in your classes, including your name in the top comment block. Avoid redundancy and be conservative in your use of fields - if a data value does not need to persist over the life of the object, declare it to be local to the method that needs it.