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

  • Language Java Step 1: Design a class called Student. The Student class should contain the following...

    Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...

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

  • import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {   ...

    import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {        Student s1 = new Student();         Student s2 = new Student("Smith", "123-45-6789", 3.2);         Student s3 = new Student("Jones", "987-65-4321", 3.7);         System.out.println("The name of student #1 is ");         System.out.println("The social security number of student #1 is " + s1.toString());         System.out.println("Student #2 is " + s2);         System.out.println("the name of student #3 is " + s3.getName());         System.out.println("The social security number...

  • Hello, Can you please error check my javascript? It should do the following: Write a program...

    Hello, Can you please error check my javascript? It should do the following: Write a program that uses a class for storing student data. Build the class using the given information. The data should include the student’s ID number; grades on exams 1, 2, and 3; and average grade. Use appropriate assessor and mutator methods for the grades (new grades should be passed as parameters). Use a mutator method for changing the student ID. Use another method to calculate the...

  • The code is attached below has the Account class that was designed to model a bank account.

    IN JAVAThe code is attached below has the Account class that was designed to model a bank account. An account has the properties account number, balance, annual interest rate, and date created, and methods to deposit and withdraw funds. I need creat program using the 2 java programs.Create two subclasses for checking and savings accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn.I need to write a test program that creates objects of Account,...

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