Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What are the main purposes of sales promotion?

Answered: 1 week ago

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago