Create a Java NetBeans project named StudentClient with the main class named Stu
ID: 3851710 • Letter: C
Question
Create a Java NetBeans project named StudentClient with the main class named StudentClient. Add a service class to the project named Student. This program will encapsulate the concept of a student, assuming a student has the following attributes (instance variables): a name, a social security number and a GPA (e.g., 3.5).For the Student class you will write the constructors, accessors and mutators, and toString and equals methods. In the client application class you will instantiate student class objects and write statements (method calls) to test the methods in your student service class. Download and follow the instructions in the attached file above to complete Programming Exercise 3. After successfully compiling and executing your exercise upload the zipped project folder to Programming Exercise 3Explanation / Answer
We cannot upload zip file here so iam sending the java files.
you create a project in netBeans folder with project name StudentClinet and create new package named studentclinet and create new java class named StudentClinet and Student files and simply copy paste the below files to your project files as it is.
StudentClient.java
package studentclient;
public class StudentClient {
public static void main(String[] args) {
Student s1=new Student("Tom","S2345",9.4);
Student s2=new Student("Jerry","P6589",8.5);
System.out.println(s1);
System.out.println(s2);
if(s1.equals(s2))
{
System.out.println("Both objects are equal");
}
else
{
System.out.println("both objects are not equal");
}
s2.setStudentName(s1.getStudentName());
s2.setSSN(s1.getSSN());
s2.setGPA(s1.getGPA());
if(s1.equals(s2))
{
System.out.println("Both objects are equal");
}
else
{
System.out.println("both objects are not equal");
}
}
}
Student.java
package studentclient;
public class Student {
private String studentName;
private String SSN;
private double GPA;
public Student(String studentName, String sSN, double gPA) {
super();
this.studentName = studentName;
SSN = sSN;
GPA = gPA;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getSSN() {
return SSN;
}
public void setSSN(String sSN) {
SSN = sSN;
}
public double getGPA() {
return GPA;
}
public void setGPA(double gPA) {
GPA = gPA;
}
@Override
public String toString() {
return "Student [studentName=" + studentName + ", SSN=" + SSN + ", GPA=" + GPA + "]";
}
public boolean equals(Student obj) {
// TODO Auto-generated method stub
if(this.studentName==obj.studentName&& this.GPA==obj.GPA&&this.SSN==obj.SSN)
{
return true;
}
else
return false;
}
}