java question please help PROGRAM Implement a class called Student. A student ha
ID: 3887236 • Letter: J
Question
java question please help
PROGRAM Implement a class called Student. A student has a first name and a last name A student has an address A student has a grade point average GPA A student has a unique student number that is given 'by the system, A student has a login id that can be obtained (you do not need to check for uniqueness of the login id - just follow the rules below on assigning the login id) · · Supply appropriate constructors and public methods for the Student class. Provide the following methods getName . getAddress addCourse » calculateGPA getStudentNum getLoginldExplanation / Answer
Here is the code for the Student.java class:
class Student
{
String firstName;
String lastName;
String address;
double GPA;
int studentNumber;
String loginID;
static int number = 7777;
public Student()
{
firstName = "No";
lastName = "Name";
address = "Nomad";
GPA = 0;
studentNumber = number;
number++;
loginID = "" + firstName.charAt(0);
if(lastName.length() <= 3)
loginID += lastName;
else
loginID += lastName.substring(0, 3);
loginID += (1 + (studentNumber - 1) % 9);
}
public Student(String fName, String lName, String add)
{
firstName = fName;
lastName = lName;
address = add;
GPA = 0;
studentNumber = number;
number++;
loginID = "" + firstName.charAt(0);
if(lastName.length() <= 3)
loginID += lastName;
else
loginID += lastName.substring(0, 3);
loginID += (1 + (studentNumber - 1) % 9);
}
public String getName() { return firstName + " " + lastName; }
public String getAddress() { return address; }
public void addCourse(double gpa, int numOfCredits) { GPA += gpa; }
public void calculateGPA() {}
public int getStudentNum() { return studentNumber; }
public String getLoginId() { return loginID; }
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.