Question

Add additional information to the student class below such as name, address, major, and contact information...

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.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go this code and let me know if u need any changes in this.Thank You
_________________

// Student.java

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
   }

   // 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
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public String getAddress() {
       return address;
   }

   public void setAddress(String address) {
       this.address = address;
   }

   public String getMajor() {
       return major;
   }

   public void setMajor(String major) {
       this.major = major;
   }

   public String getContactInfo() {
       return contactInfo;
   }

   public void setContactInfo(String contactInfo) {
       this.contactInfo = contactInfo;
   }

}

______________________

// ShowStudent.java

//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.setName("Kane Williams");
       pupil.setAddress("101,church Mumbai");
       pupil.setContactInfo("9845566678");
       pupil.setMajor("Computer Science");
       System.out.println("Name :"+pupil.getName());
       System.out.println("Major :"+pupil.getMajor());
       System.out.println("Contact Info :"+pupil.getContactInfo());
       System.out.println("Address :"+pupil.getAddress());
       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
   }
}

____________________________

Output:

Name :Kane Williams
Major :Computer Science
Contact Info :9845566678
Address :101,church Mumbai
ID Number is: 234
Points Earned: 47
Credit Hours: 15
The grade point average is 3.1333333333333333

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Add additional information to the student class below such as name, address, major, and contact information...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Add additional information to the student class below such as name, address, major, and contact information...

    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...

  • Write a program in Java that prompts a user for Name and id number. and then...

    Write a program in Java that prompts a user for Name and id number. and then the program outputs students GPA MAIN import java.util.StringTokenizer; import javax.swing.JOptionPane; public class Main {    public static void main(String[] args) {                       String thedata = JOptionPane.showInputDialog(null, "Please type in Student Name. ", "Student OOP Program", JOptionPane.INFORMATION_MESSAGE);        String name = thedata;        Student pupil = new Student(name);                   //add code here       ...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • Writing 3 Java Classes for Student registration /** * A class which maintains basic information about...

    Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course {    /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...

  • Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters...

    Modify the objectstudent JAVA program to add a private variable zipcode, you must also add setters and getter methods for the new variable and modify the toString method. The objectstudent program is in this weeks module, you can give it a default value of 19090. class Student { private int id; private String name; public Student() { id = 8; name = "John"; } public int getid() { return id; } public String getname() { return name; } public void...

  • Given a class called Student and a class called Course that contains an ArrayList of Student....

    Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called getDeansList() as described below. Refer to Student.java below to learn what methods are available. I will paste both of the simple .JAVA codes below COURSE.JAVA import java.util.*; import java.io.*; /****************************************************** * A list of students in a course *****************************************************/ public class Course{     /** collection of Students */     private ArrayList<Student> roster; /***************************************************** Constructor for objects of class Course *****************************************************/...

  • Create an abstract Student class for Parker University. The class contains fields for student ID number,...

    Create an abstract Student class for Parker University. The class contains fields for student ID number, last name, and annual tuition. Include a constructor that requires parameters for the ID number and name. Include get and set methods for each field; the setTuition() method is abstract. Create three Student subclasses named UndergraduateStudent, GraduateStudent, and StudentAtLarge, each with a unique setTuition() method. Tuition for an UndergraduateStudent is $4,000 per semester, tuition for a GraduateStudent is $6,000 per semester, and tuition for...

  • This is a simple C++ class using inheritance, I have trouble getting the program to work....

    This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...

  • Last picture is the tester program! In this Assignment, you will create a Student class and...

    Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT