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

Create a class named Student. A Student has fields for a name, an ID number, num

ID: 3642059 • Letter: C

Question

Create a class named Student. A Student has fields for a name, an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields (setters or mutators). A Student also has a field for grade point average. Include a method to compute the grade point average field by dividing points by credit hours earned. Write methods to display the values in each Student field. Save this class as Student.java.
Add a constructor for the Student class you created. The constructor should initialize the student name to “Anonymous“, the Student’s ID number to 9999, his or her points earned to 12, and credit hours to 3 (resulting in a grade point average of4.0). Write a program that demonstrates that the constructor works by instantiating an object and displaying the initial values. Save the application as ShowStudent2.java.
Write a class named ShowStudent that instantiates a Student object from the class you created and assign values to its fields. Compute the Student grade point average, and then display all the values associated with the Student. Save the application as ShowStudent.java.

Explanation / Answer

public class Student {

       private String name;

       private int ID;

       private int creditHours;

       private double points;

       private double GPA;

       public Student() {

              name = "Anonymous";

              ID = 9999;

              points = 12;

              creditHours = 3;

              computeGPA();

       }

       public void setName(String name) {

              this.name = name;

       }

       public void setID(int iD) {

              ID = iD;

       }

       public void setCreditHours(int creditHours) {

              this.creditHours = creditHours;

       }

       public void setPoints(double points) {

              this.points = points;

       }

       public void computeGPA() {

              GPA = points/creditHours;

       }

       public double getGPA() {

              return GPA;

       }

       public String getName() {

              return name;

       }

       public int getID() {

              return ID;

       }

       public int getCreditHours() {

              return creditHours;

       }

       public double getPoints() {

              return points;

       }

}

public class ShowStudent2 {

       public static void main(String[] args) {

              Student>new Student();

              System.out.println("Student " + one.getID() + ": " + one.getName() + " has earned "

                           + one.getPoints() + " points over " + one.getCreditHours() + " credit hours and has a GPA of "

                           + one.getGPA());

       }

}

public class ShowStudent {

       public static void main(String[] args) {

              Student>new Student();

              one.setID(1001);

              one.setName("Bobby");

              one.setPoints(18);

              one.setCreditHours(6);

              one.computeGPA();

              System.out.println("Student " + one.getID() + ": " + one.getName() + " has earned "

                           + one.getPoints() + " points over " + one.getCreditHours() + " credit hours and has a GPA of "

                           + one.getGPA());

       }

}

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