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()
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().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
CODE IN JAVA Studentjava file public class Student fields of the class private String ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Statistics For Business And Economics
Authors: David R. Anderson, Dennis J. Sweeney, Thomas A. Williams
11th Edition
978-0324783254, 324783256, 978-0324783247, 324783248, 978-0538481649
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App