Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So... I was given the following java program to write using codeblocks. Im new a

ID: 3917172 • Letter: S

Question

So... I was given the following java program to write using codeblocks. Im new at java so just looking at this confuses me

After you have created your NetBeans Project your application class StudentClient should contain the following executable code:

package studentclient;public class StudentClient {

public static void main(String[] args) { }

}
Your service class should contain the following executable code:

package studentclient;public class Student {
}

In the StudentClient application class main method code the instructions to perform the tasks indicated in the remarks :

package studentclient;
public class StudentClient{

public static void main( String [] args ){

/* Declare two object references of type Student s1 and s2 and instantiate two Student objects passing three arguments to the constructor for the class. Use different values for each class object */

/* Output the name, social security number and GPA of the student from object reference s1 using the appropriate accessor methods to obtain the data */

/* Output the name, social security number and GPA of the student from object reference s2 using the toString method to return the data */

} }

{

/* Using the equals method and a selection control structure (if statement), compare objects s1 and s2 and output an appropriate message indicating if the objects are equal */

/* Using the appropriate mutator methods on student object s2, change the name, social security number and GPA to the same values as in object s1. Use the set methods. */

/* Again, using the equals method and a selection control structure (if statement), compare objects s1 and s2 and output an appropriate message indicating if the objects are equal */

In the Student service class code the instructions to define your Student service class structure with the appropriate constructors, mutator methods, accessor methods as well as a toString and an equals method :

package studentclient;public class Student

/* Declare three instance variables to represent the student name, social security number and GPA */

/* Overloaded constructor method:
Allows client to set beginning values for name,
ssn, and gpa. This constructor takes three parameters and calls mutator methods to validate new values */

public Student( String newName, String newSsn, double newGpa ) {

public String getName( ) {

public void setName( String newName ) {

}

public String getSsn( ) {

public void setSsn( String newSsn ) {

public double getGpa( ) {

}

public void setGpa( double newGpa ) {

}

public String toString( ) {

/* setGpa mutator method: Allows client to set value of gpa and prints an error message if new value is either less than 0 or greater than 4.0. setGpa does not change the value of gpa if newGpa is negative or greater than 4.0 */

/* toString method returns student name, social security number and GPA */

}

public boolean equals( Object o ) {

} }

Explanation / Answer

StudentClient.java

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" );
}
}

Student.java

public class Student {

private String name;

private String ssn;

private double gpa;

public Student(String n, String s, double g){

name = n;

gpa = g;

ssn = s;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getSsn() {

return ssn;

}

public void setSsn(String ssn) {

this.ssn = ssn;

}

public double getGpa() {

return gpa;

}

public void setGpa(double gpa) {

this.gpa = gpa;

}

public String toString(){

return "name is "+name+" ssn is "+ssn+" gpa is "+gpa;

}

public boolean equals(Student s){

if(this.name == s.name && this.ssn == s.ssn){

return true;

}

else{

return false;

}

}

}

Output:

The name of student #1 is Jones
The social security number of student #1 is 222-88-1111
The gpa of student #1 is 3.7
Student #2 is name is Smith ssn is 333-99-4444 gpa is 3.2
Original students #1 and #2 are different
Original student #1 and modified student #2 are identical

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote