Question: You will be using inheritance, abstract classes, the Comparable interface and writing to a file. You will also need to create a custom exception which

You will be using inheritance, abstract classes, the Comparable interface and writing to a file. You will also need to create a custom exception which you must use and catch.

Create an abstract class Student. This class should contain instance variables as follows:

String name must be at least 1 character but not more than 10 characters.

double GPA must be from 0.0 to 4.0

methods

abstract reaction() returns a String

toString() returns name and GPA

getters/setters

constructors as needed

Should implement the Comparable interface. Compare on the name of the student

Create a HappyOne class that extends Student

Implement the abstract reaction method return Yippy-kai-Yay!

Create a toString() method should print the type of student add the Student toString() and append the results of the reaction method.

Create a SadOne class that extends Student

Implement the abstract method returns oh @###!!!&&&^^^%.

Create a toString() method should print the type of student add the Student toString() and append the results of the reaction method.

Create an InvalidStudentException which will be used if an invalid student is entered.

Create a StudentTester class.

Create an array of Students at least 5 Students.

Using the calculation:

If GPA >= 3.0 = Assign HappyOne to the array.

if GPA < 3.0 = Assign SadOne to the array.

You will need a method to allow users to enter the name and GPA. This cannot be static.

Write the original array to a file.

Sort the array.

Write the sorted array to the same file.

Read the file and print the results.

You must use your custom exception to tell the user if their entry is invalid.

Sample output:

Please enter the student's name.

Bob

Please enter the GPA for Bob.

4

Yippy-kai-Yay!

Please enter the student's name.

You must enter a name.

Please enter the student's name.

A really long student name

A really long student name is not a valid name.

Please enter the student's name.

Alice

Please enter the GPA for Alice.

4

Please enter the student's name.

Nobody

Please enter the GPA for Nobody.

-4

A student must have between 0.0 and 4.0 GPA.

Please enter the GPA for Nobody.

6

A student must have between 0.0 and 4.0 GPA.

Please enter the number of GPA for Nobody.

2

Please enter the student's name.

Buddy

Please enter the GPA for Buddy.

4

Please enter the student's name.

Romena

Please enter the GPA for Romena.

2

Unsorted List:

HappyOne Bob 4.0 Yippy-kai-Yay!

HappyOne Alice 4.0 Yippy-kai-Yay!

SadOne Nobody 2.0 oh @###!!!&&&^^^%

HappyOne Buddy 4.0 Yippy-kai-Yay!

SadOne Romena 2.0 oh @###!!!&&&^^^%

Sorted List:

HappyOne Alice 4.0 Yippy-kai-Yay!

HappyOne Bob 4.0 Yippy-kai-Yay!

HappyOne Buddy 4.0 Yippy-kai-Yay!

SadOne Nobody 2.0 oh @###!!!&&&^^^%

SadOne Romena 2.0 oh @###!!!&&&^^^%

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!