Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 ... 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

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

More Books

Students also viewed these Programming questions

Question

b. Who is the program director?

Answered: 1 week ago

Question

Find the magnitude of a. b. c.

Answered: 1 week ago