Question: JAVA QUESTION. 59. Write a class encapsulating the concept of a student, assuming a student has the following attributes: a name,a social security number, and

JAVA QUESTION.

59. Write a class encapsulating the concept of a student, assuming a student has the following attributes: a name,a social security number, and a GPA (for instance, 3.5). Include a constructor, the accessor and mutator, and methods toString and equals. Write a client class to test all the methods in your class. BELOW IS THE CLIENT AND I NEED A TEST CLASS!

public class StudentClient { public static void main( String [] args ) { Student s1 = new Student( "Jones", "222-88-1111", 3.7 ); Student s2 = new Student( "Smith", "333-99-4444", 3.2 ); System.out.println( "The name of student #1 is " + s1.getName( ) ); System.out.println( "The social security number of student #1 is " + s1.getSsn( ) ); System.out.println( "The gpa of student #1 is " + s1.getGpa( ) ); System.out.println( "Student #2 is " + s2.toString( ) );

if ( s1.equals( s2 ) ) System.out.println( "Original students #1 and #2 are identical" ); else System.out.println( "Original students #1 and #2 are different" );

s2.setName( "Jones" ); s2.setSsn( "222-88-1111" ); s2.setGpa( 3.7 );

if ( s1.equals( s2 ) ) System.out.println( "Original student #1 and modified student #2 are identical" ); else System.out.println( "Original student #1 and modified student #2 are different" );

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!