Question: Consider a Student class that has: private instance variables: final int id final String studentName double[] quizGrades Appropriate one argument constructor that throws IllegalArgumentException, this

Consider a Student class that has:

private instance variables:

final int id

final String studentName

double[] quizGrades

Appropriate one argument constructor that throws IllegalArgumentException, this Constructor is to be used to create a dummy search object.

Appropriate three argument constructor that throws IllegalArgumentException

A copy constructor.

Appropriate get methods.

public double getQuizAverage( )

public String toString( ) // returns a formatted string containing id, studentName, and five quiz grades.

public boolean equals(Object obj) // comparison based on id only

Consider an ICS102Section class that has:

private instance variables:

int sectionNumber

int numStudents

Student[ ] students

final int MAXIMUMCAPACITY that is initialized to 30

A constructor: public ICS102Section(int sectionNumber, int numStudents) that throws IllegalArgumentException.

// Note: sectionNumber > 0 and 5 <= numStudents <= 30

The following methods:

getSectionNumber

getNumStudents

getStudentArray

getSectionQuizAverage(int numQuiz) that throws IllegalArgumentException. The method returns the section quiz average for quiz number numQuiz.

addStudent(Student s) that throws IllegalArgumentException. The method adds student s to the array students if possible.

public String toString() // returns a formatted string containing id, studentName, and five quiz grades.

Implement a well-structured Java program that uses the Student, ICS102Section and SectionDriver classes to enable an instructor to maintain the grades of 5 quizzes for a class that has a maximum capacity of 30 students. The quiz grades are kept in a text-file grades.txt of the form:

201216700 Salim Yusuf 2.0 3.0 2.5 4.0 3.2

201232980 Ahmad Muhsin 3.0 3.0 4.5 4.0 4.4

201248580 Qasim Hussein 4.0 4.2 3.5 3.0 2.6

201270620 Redha Muhammad 5.0 4.0 4.6 5.0 3.7

201304790 Zakariya AbdulQader 2.2 3.0 3.5 4.2 3.3

201315890 Yaman Khan 3.4 3.0 2.5 4.0 3.2

201317590 Sulaiman Omar 5.0 5.0 5.0 5.0 5.0

201320710 Muhammad Ramadhan 4.0 3.0 3.1 4.0 3.2

201335050 Zulfikar Abeid 2.1 2.0 4.5 3.1 3.0

201337430 Abubakar Hassan 3.8 3.0 4.0 4.0 3.2

201356030 Ali AbdulLatif 2.0 2.8 2.6 4.0 3.2

201391930 Abdallah Qasim 5.0 3.0 4.8 5.0 5.0

201425900 Jamal Zaid 2.9 3.0 2.5 4.2 3.2

201427560 Muhsin Sadeq 4.1 5.0 5.0 4.0 3.2

201428140 Ayoub Muhammad 3.2 3.4 3.3 4.0 4.2

201429700 Haroun Yahya 5.0 3.0 4.6 5.0 3.7

201436500 AbdulAziz Zubeir 2.5 3.7 2.0 4.0 4.5

201446740 Muhammad Ali 4.0 5.0 3.3 5.0 3.2

201457400 AbduRauf Hamad 5.0 3.2 5.0 4.6 5.0

201462540 Jamal Rashid 2.8 3.0 2.5 4.0 3.2

where each line of the text-file contains a unique student ID, his first name (a single word), his second name (a single word), followed by five quiz grades. The minimum quiz grade is 0.0 and the maximum is 5.0

Your SectionDriver program must have the following main menu:

1. Display all students.

2. Display section quiz average for a particular quiz.

3. Display a student and his quiz average.

4. Exit.

Please enter your choice:

Your program must loop as long as option 4 has not been selected. It must display an appropriate error message if an invalid choice is entered. After executing each of the options 1 to 3, your program must pause and display the message: Press Enter key to continue . . . . Your program must display the main menu after pressing the Enter key. Each of the options 1 to 3 must be implemented in a separate private static method. The code for Press Enter key to continue . . . must also be implemented is a separate private static method. Your main method must handle IllegalArgumentException, and InputMismatchException by displaying an appropriate error message, then waiting for a key press, before returning control to the main menu.

Your program must start by creating an ICS102Section object with a maximum capacity of 30, it then calls a private static method that adds students to the section by reading from the text-file grades.txt. After this initialization, each of the options 1, 2, and 3 must be done using the section object and not the text-file.

The options must have the following behaviors:

Option 1: Display all students.

It displays on the monitor the quiz information of all students. It then waits for the Enter key to be pressed before returning control to the main menu.

Option 2: Display section quiz average for a particular quiz.

The option prompts for and reads a quiz number. If the quiz number is valid, the section average of that quiz is displayed on the monitor; otherwise an error message is displayed. In both cases, the option waits for the Enter key to be pressed before returning control to the main menu.

Option 3. Display a student and his quiz average.

The option prompts for and reads a student ID. If the student exists in the section object his quiz grades and his quiz average are displayed on the monitor; otherwise an appropriate error message is displayed. Control is then returned to the main menu after pressing the Enter key.

Note:

Your program must not use parallel arrays. IT MUST USE an array of Student references that is contained in the ICS102Section object.

Your program must not use 2D-arrays.

Your program must not use static variables.

The classes Student and ICS102Section must not contain code that is to be in the SectionDriver class.

The classes Student and ICS102Section must not have reference leaks.

Use the clause throws FileNotFoundException or throws IOException for each method that performs File I/O.

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!