Question: In this java file, create a default class named Student. The Student class should have a static variable, numStudent, and five instance variables. 1 .

In this java file, create a default class named Student. The Student class should have a static variable, numStudent, and five instance variables.

1. Write the following variables: Static variable

numStudent: the number of the student objects that have been created, static, int, initial value = 0. Instance variables

name: the students full name, String, e.g., John Doe, must be specified when instantiated.

id: the students id, String, created based on numStudent, e.g., the first student objects id should be 1, the second student objects id should be 2.

major: the students major, String, must be specified when instantiated. Page | 2

gpa: the student's current gpa, double, initial value = 0.0.

username: String, each student is assigned an automatically generated username following the rules below:

Get the first letter of the students first name.

Get the first five letters of the students last name. If students last name is less than the required number of letters in length, then use the entire name.

Get the students id

. Concatenate the three sets of letters then convert to lower case to generate the login name.

2. Write the constructor.

3. Implement the Comparable interface. Student should be able to be compared by their gpa.

Test cases: Student s1 = new Student(John Doe, Computer Science); // id is 1, username is jdoe1 Student s2 = new Student(Emily Johnson, Cybersecurity); // id is 2, username is ejohns2 int result = s1.compareTo(s2);

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!