Question: HW1 : Grade Report Generator Objective : To understand the principles of OOP like inheritance and polymorphism and apply the knowledge of dynamic binding to

HW1 : Grade Report Generator

Objective : To understand the principles of OOP like inheritance and polymorphism and apply the knowledge of dynamic binding to improve code reusability.

Assignment Details

Part I

  1. You have been tasked to design a system that stores student grade information for a university. To do so you will be designing a set of classes that stores and processes student grade information for different courses. To be more specific, you should design one base class (Student) to store common data, and three derived classes that divide the set of students into three categories: Physics students, History students, and Math students. All data stored in these classes should be either private or protected. Any access to class data from outside should be done through getter and setter functions. The base class should contain the following attributes:
    1. student's first name
    2. student's last name
    3. course the student is in (History, Math or Physics)
  2. To store the last attribute, you should use an enum type which allows you to declare a datatype with custom values.

Declare your Enum as a separate class, inside the base class .java file. Do not declare it inside the base class, just in the same file.

  1. Your base class MUST NOT contain any other attributes other the 3 attributes mentioned above. You may however declare methods that you intend to override in the child classes.

Part II

Implement 3 child classes that inherit from the base class. Each class should contain a method that returns the final average based on the stored grades. All grades are out of 100. Each course has a different criteria for computing the final grade as shown below.

History Students: The raw final average is computed using the weight criteria below.

Attendance

10%

Project

30%

Midtem

30%

Final Exm

30%

The final average is then computed by curving the raw final average using the formula :

Final Average= 10 x Raw Final Average

Math Students: The final average is computed using the weight criteria below

Quiz (Average out of 5 quizzes)*

20%

Midtem 1

25%

Midtem 2

25%

Final Exm

30%

*The quiz average will be computed by averaging the scores on all 5 quizzes and then multiplied with the quiz weight.

Physics Students: The final average is computed using the weight criteria below

Labs (Best 2 out of 3) *

20%

Research Paper

25%

Midtem

25%

Final Exm

30%

*The lab average will be computed by dropping the lowest score out of 3 labs and taking the average of the other 2.

Part III

Implement a separate class StudentList, which will contain single Arraylist to store the list of various students. Note the variable reference for this array will be of type base class, and you should use the principle of polymorphism to execute the appropriate methods

Your StudentList class MUST contain the following methods. Please make sure the method signatures match exactly what is shown here.

  • public StudentList() no arg constructor which will initialize an empty arrayList of students.
  • public void importFromFile(String fname) should read in a file and populate your arraylist. The format of this file is listed below.
  • public void generateReport(String fname) should accept a string parameter as a filename and export a detailed report of the student, in the format shown in the sample output.
  • public void showList() should output a list of students with their first name , last name and course name
  • public void sortStudentList() should sort the list of students alphabetically based on their last name. If the last names match, they should be sorted on the basis of their first name. The method should sort the student list in-place. The method should not output anything, however if the user were to invoke listStudents(), they should now see the student list in alphabetical order.

In addition to the above methods, you are free to declare as many utility methods as you would like. Make sure to keep these private, so that they are only accessible from within your StudentList class

Part IV

Write a test program that offers a menu driven choice to the user. You should present the user with the following options (should loop infinitely, until user quits)

*** Report Generator ***

I Import students from file

L Show student roster

E Export a grade report

S Sort Student List

M Show this Menu

Q Quit Program

File Formats

Input File Format

The input file will contain an arbitrary length list of student records. Each record spans across 2 lines. The first line contains the last name, first name for the student. The second line contains their scores in their respective courses in the following format

History -- Attendance, Project, Midtem, Final Exm

Physics Lab1, Lab2, Lab3, Research Paper, Midtrm, Final Exm

Math -- Quiz 1, Quiz 2, Quiz 3, Quiz 4, Quiz 5, Test 1, Test 2, Final Exm

For example,

Thomas, Dean Physics 60 72 78 72 78 79

Output File Format

The output file should be generated when the user selects option E. The format should be as follows.

  1. You should print the final averages for each student grouped by their courses.
  2. For each course and each student, print the students
  • first name,
  • last name,
  • final exm score
  • final average (rounded up to 2 decimal places).
  1. In addition, also print the letter grade based on the following criteria

A

>=90

B

89.99 - 80

C

79.99 - 70

D

69.99 - 60

F

<60

Each course should have appropriate headers (see sample output below) and all columns should be left-aligned.

  1. Finally, at the end of the file, print a distribution of grades i.e. how many students received As , Bs etc.

Sample Input file

Granger, Hermione Math 90 86 80 95 100 99 96 93 Longbottom, Neville Physics 88 75 90 78 90 45 Weasley, George History 95 76 85 91 Krum, Victor Math 44 58 23 76 50 59 77 68 Snape, Severus History 40 100 68 88 Thomas, Dean Physics 60 72 78 72 78 79 Diggory, Cedric Physics 80 92 98 92 89 99 Malfoy, Draco Math 74 38 23 16 50 61 51 88 Weasley, Fred History 40 100 68 88

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!