Instructions Add additional information to the student class below such as name,
ID: 3709732 • Letter: I
Question
Instructions
Add additional information to the student class below such as name, address, major, and contact information along with all the getters and setters (methods) needed to access all data. Submit your code along with a sample run of your program. Comment all your code. Cite any sources of information you use. Write a note on the process of completing the assignment in a Microsoft Word document.
// ShowStudent.java
// client to test the Student class
class ShowStudent
{
public static void main (String args[])
{
Student pupil = new Student(); // We need a new student named pupil
pupil.setIDnumber(234); // We are setting pupil's ID number to 234
pupil.setPoints(47); // We are setting pupil's points to 47
pupil.setHours(15); // We are setting pupil's hours to 15
pupil.showIDnumber(); // We are showing pupil's ID number
pupil.showPoints(); // We are showing pupil's points
pupil.showHours(); // We are showing pupil's hourse
System.out.println("The grade point average is " +
pupil.getGradePoint()); // we are calculating pupil's GPA
}
}
class Student // this is the student class
{
// the private data members
private int idNumber;
private int hours;
private int points;
// Constructor creates a new student
Student()
{
idNumber = 9999; // a max ID
points = 12; // starting out assuming 12 points
hours = 3; // starting out assuming 3 hours
}
// end of constructor
// the public get and set methods fro pulil specific information
public void setIDnumber(int number) // pass in a number
{
idNumber = number; // assign the number
}
public int getIDnumber() // return a student ID
{
return idNumber;
}
public void setHours(int number) // pass in a number
{
hours = number; // assign the number to hours
}
public int getHours() // return the student's hours
{
return hours;
}
public void setPoints(int number) // pass in a number
{
points = number; // assign number to points
}
public int getPoints() // return the points
{
return points;
}
// methods to display the fields
public void showIDnumber()
{
System.out.println("ID Number is: " + idNumber);
}
public void showHours()
{
System.out.println("Credit Hours: " + hours);
}
public void showPoints()
{
System.out.println("Points Earned: " + points);
}
public double getGradePoint() // calculate the GPA with internal data
{
return (points * 1.0 / hours);
// simple integer division will truncate the decimal places
}
}
Submission Details:
Create the code and sample run files.
Write the process of completing the assignment in a Microsoft Word document.
Zip the files as SU_ITS2105_W3_A2_LastName_FirstInitial.zip.
Submit your document to the Submissions Area by the due date assigned.
Attachments
Explanation / Answer
class Student // this is the student class
{
// the private data members
private int idNumber;
private int hours;
private int points;
private String name;
private String address;
private String major;
private String contactInfo;
// Constructor creates a new student
Student()
{
idNumber = 9999; // a max ID
points = 12; // starting out assuming 12 points
hours = 3; // starting out assuming 3 hours
name = "Harris Jones";
address = " 1957- Downtown Street, Dallas- TX";
major = "Computer Science";
contactInfo = "666-797980";
}
// end of constructor
// the public get and set methods fro pulil specific information
public void setIDnumber(int number) // pass in a number
{
idNumber = number; // assign the number
}
public int getIDnumber() // return a student ID
{
return idNumber;
}
public void setHours(int number) // pass in a number
{
hours = number; // assign the number to hours
}
public int getHours() // return the student's hours
{
return hours;
}
public void setPoints(int number) // pass in a number
{
points = number; // assign number to points
}
public int getPoints() // return the points
{
return points;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setAddress(String address)
{
this.address = address;
}
public String getAddress()
{
return address;
}
public void setMajor(String major)
{
this.major = major;
}
public String getMajor()
{
return major;
}
public void setContactInfo(String contactInfo)
{
this.contactInfo = contactInfo;
}
public String getContactInfo()
{
return contactInfo;
}
// methods to display the fields
public void showIDnumber()
{
System.out.println("ID Number is: " + idNumber);
}
public void showHours()
{
System.out.println("Credit Hours: " + hours);
}
public void showName()
{
System.out.println("Name : "+name);
}
public void showAddress()
{
System.out.println("Address : "+address);
}
public void showMajor()
{
System.out.println("Major : "+major);
}
public void showContactInfo()
{
System.out.println("Contact Information : "+contactInfo);
}
public void showPoints()
{
System.out.println("Points Earned: " + points);
}
public double getGradePoint() // calculate the GPA with internal data
{
return (points * 1 / hours);
// simple integer division will truncate the decimal places
}
}
// ShowStudent.java
// client to test the Student class
class ShowStudent
{
public static void main (String args[])
{
Student pupil = new Student(); // We need a new student named pupil
pupil.setIDnumber(234); // We are setting pupil's ID number to 234
pupil.setName("Andrew Hudson");
pupil.setAddress("1957- Downtown Street, Dallas- TX");
pupil.setMajor("Physics");
pupil.setContactInfo("657-65868");
pupil.setPoints(47); // We are setting pupil's points to 47
pupil.setHours(15); // We are setting pupil's hours to 15
pupil.showIDnumber(); // We are showing pupil's ID number
pupil.showName(); // We are showing pupil's name
pupil.showAddress(); // We are showing pupil's address
pupil.showMajor(); // We are showing pupil's major subject
pupil.showContactInfo(); // We are showing pupil's phone number
pupil.showPoints(); // We are showing pupil's points
pupil.showHours(); // We are showing pupil's hourse
System.out.println("The grade point average is " +
pupil.getGradePoint()); // we are calculating pupil's GPA
}
}
Output:
ID Number is: 234
Name : Andrew Hudson
Address : 1957- Downtown Street, Dallas- TX
Major : Physics
Contact Information : 657-65868
Points Earned: 47
Credit Hours: 15
The grade point average is 3.0
Do ask if any doubt. Please upvote.