Create a class named student. a student has fields for 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. 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.

Respuesta :

/****************

* Student.java *

****************/

public class Student

{

   int sid;

   int credithours;

   int points;

   double averagegrade;

 // constructor to assign initial values

   public Student() {

       this.sid = 9999;

       this.credithours = 3;

       this.points = 12;

   }

 // methods to assign values to all fields.

   public void setCredithours(int credithours) {

       this.credithours = credithours;

   }

   public void setPoints(int points) {

       this.points = points;

   }

   public void setSid(int sid) {

       this.sid = sid;

   }

 // method to compute the grade point average field by dividing points by credit hours earned.

   public void computeAveragegrade()

   {

       this.averagegrade = this.points / this.credithours;

   }

 // methods to display the values in each Student field

   public void showSid(){

       System.out.println("Student id is : " + this.sid);

   }

   public void showPoints(){

       System.out.println("Number of points earned : " + this.points);

   }

   public void showCredithours(){

       System.out.println("Number of credit hours earned : " + this.credithours);

   }

   public void showAveragegrade(){

       System.out.println("Average grade point is : " + this.averagegrade);

   }

}