public class Student { private String name; private String major; privatedoublegpa; privateinthoursCompleted;     /**Constructor * @param name * The student's name * @param major * The student's major */ public Student(String name, String major) { this.name = name; this.major = major; this.gpa = 0.0; hoursCompleted = 0; }   /**Constructor * @param name * The student's name * @param major * The student's major * @param gpa * The student's cumulative gpa * @param hoursCompleted * Number of credit hours the student has completed */ public Student(String name, String major, doublegpa, inthoursCompleted) { this.name = name; this.major = major; this.gpa = gpa; this.hoursCompleted = hoursCompleted; }   /** * @return The student's major. */ public String getMajor() { returnmajor; } /** * @param major The major to set. */ publicvoid setMajor(String major) { this.major = major; } /** * @return The student's name. */ public String getName() { returnname; } /** * @param name The name to set. */ publicvoid setName(String name) { this.name = name; } /** * @return The student's gpa. */ publicdouble getGpa() { returngpa; } /** * @return The number of credit hours the student has completed. */ publicint getHoursCompleted() { returnhoursCompleted; }   /** * @return The student's class (Freshman, Sophomore, Junior, Senior) */ publicString getClassLevel() { String classLevel; if (hoursCompleted < 30) { classLevel = "Freshman"; } elseif (hoursCompleted < 60) { classLevel = "Sophomore"; } elseif (hoursCompleted < 90) { classLevel = "Junior"; } else { classLevel = "Senior"; } returnclassLevel; }   /**Update student's information to reflect completion of a semester's work * @param semHours * Number of credit hours the student has just completed * @param semGPA * GPA for the semester just completed */ publicvoid updateStudent(intsemHours, doublesemGPA) { intoldHours = hoursCompleted; hoursCompleted = oldHours + semHours; gpa = (oldHours *gpa + semHours * semGPA) / hoursCompleted; }   /** Print the student's name and class */ publicvoid printClassLevel() { System.out.println(name + " is a " + getClassLevel()); }   /**Prints the information about a student in a nice format with * appropriate labeling */ publicvoid print() { DecimalFormat fmt = new DecimalFormat("0.000"); System.out.println(name + " is a " + getClassLevel() + " " + major); System.out.print("who has completed " + hoursCompleted + " hours "); System.out.println("with a " + fmt.format(gpa) + " gpa."); } }   public class StudentPlay {   /** * @param args */ publicstaticvoid main(String[] args) {   Student student1 = new Student("Reagan Wilson", "Music Education", 3.8, 16); Student student2 = new Student("Hillary Adams", "Marketing");   student1.printClassLevel(); student2.setMajor("Agriculture");   student1.print();   System.out.print(student1);   }   }  How would I fix main method so it is not printing out the memory location. I cannot change the code in the Student class.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

public class Student

{

private String name;

private String major;

privatedoublegpa;

privateinthoursCompleted;

 

 

/**Constructor

* @param name

* The student's name

* @param major

* The student's major

*/

public Student(String name, String major)

{

this.name = name;

this.major = major;

this.gpa = 0.0;

hoursCompleted = 0;

}

 

/**Constructor

* @param name

* The student's name

* @param major

* The student's major

* @param gpa

* The student's cumulative gpa

* @param hoursCompleted

* Number of credit hours the student has completed

*/

public Student(String name, String major, doublegpa, inthoursCompleted)

{

this.name = name;

this.major = major;

this.gpa = gpa;

this.hoursCompleted = hoursCompleted;

}

 

/**

* @return The student's major.

*/

public String getMajor()

{

returnmajor;

}

/**

* @param major The major to set.

*/

publicvoid setMajor(String major)

{

this.major = major;

}

/**

* @return The student's name.

*/

public String getName()

{

returnname;

}

/**

* @param name The name to set.

*/

publicvoid setName(String name)

{

this.name = name;

}

/**

* @return The student's gpa.

*/

publicdouble getGpa()

{

returngpa;

}

/**

* @return The number of credit hours the student has completed.

*/

publicint getHoursCompleted()

{

returnhoursCompleted;

}

 

/**

* @return The student's class (Freshman, Sophomore, Junior, Senior)

*/

publicString getClassLevel()

{

String classLevel;

if (hoursCompleted < 30)

{

classLevel = "Freshman";

}

elseif (hoursCompleted < 60)

{

classLevel = "Sophomore";

}

elseif (hoursCompleted < 90)

{

classLevel = "Junior";

}

else

{

classLevel = "Senior";

}

returnclassLevel;

}

 

/**Update student's information to reflect completion of a semester's work

* @param semHours

* Number of credit hours the student has just completed

* @param semGPA

* GPA for the semester just completed

*/

publicvoid updateStudent(intsemHours, doublesemGPA)

{

intoldHours = hoursCompleted;

hoursCompleted = oldHours + semHours;

gpa = (oldHours *gpa + semHours * semGPA) / hoursCompleted;

}

 

/** Print the student's name and class */

publicvoid printClassLevel()

{

System.out.println(name + " is a " + getClassLevel());

}

 

/**Prints the information about a student in a nice format with

* appropriate labeling

*/

publicvoid print()

{

DecimalFormat fmt = new DecimalFormat("0.000");

System.out.println(name + " is a " + getClassLevel() + " " + major);

System.out.print("who has completed " + hoursCompleted + " hours ");

System.out.println("with a " + fmt.format(gpa) + " gpa.");

}

}

 

public class StudentPlay

{

 

/**

* @param args

*/

publicstaticvoid main(String[] args)

{

 

Student student1 = new Student("Reagan Wilson", "Music Education", 3.8, 16);

Student student2 = new Student("Hillary Adams", "Marketing");

 

student1.printClassLevel();

student2.setMajor("Agriculture");

 

student1.print();

 

System.out.print(student1);

 

}

 

}

 How would I fix main method so it is not printing out the memory location. I cannot change the code in the Student class.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education