Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following class definition: public class Student { private String name; private String major; private double gpa; private int hours; public Student(String newName, String

Given the following class definition:

public class Student {

private String name;

private String major;

private double gpa;

private int hours;

public Student(String newName, String newMajor, double newGpa, int newHours) {

name = newName;

major = newMajor;

gpa = newGpa;

hours = newHours;

}

public String toString() {

// Type your code here **********

}

}

Assume that studentAmy is an Student object with the following attributes:

name is "Amy Farrell"; major is "History"; gpa is 3.87 and hours is 14. (These are all given and stored in the studentAmy object)

The following statement is trying to print the object:

System.out.println(studentAmy);

Write the toString method so that the output of object will display all information of Amy. The output will also add one of the following comment:

1. if the gpa >= 3.5 - " You are an excellent student!"

2. if the gpa >= 2.0 - "You are making your grades just fine."

3. otherwise - Woops! Need a little more effort!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago

Question

5. Develop the succession planning review.

Answered: 1 week ago