Modify the Student class to compute the graduation year. Assume all students (in a perfect world) graduate

Modify the Student class to compute the graduation year. Assume all students (in a perfect world) graduate in 4 years. Define a method named getGraduationYear() which returns the graduation year defined as 4 + the year of enrollment.

Student Class:

public class Student
{
// Declaration of instance variables
private String name;
private String major;
private int yearEnrolled;

// Constructor
public Student(String n, int y) {
name = n;
major = “undeclared”;
yearEnrolled = y;
}
public void setMajor(String m) { major = m; }
public String getMajor() { return major; }
public int getYear() { return yearEnrolled; }
public String getName() { return name; }

}

Define getGraduationYear().

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?