Modify the Student class to compute the graduation year. Assume all students (in a perfect world) graduate
Question:
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().
Statistics For Business And Economics
ISBN: 9780538481649
11th Edition
Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams