Could you implement a gpa calculator so that it asks for aletter grade for each of four classes, calculates the gpa, andprints the GPA out along with the student id, major, and name.
/*****************************Student.java*************************/
public class Student {
  // private data members
  private String id;
  private String name;
  private String major;
  private double gpa;
  // default constructor which set the data member todefualt value
  public Student() {
     this.id = \"\";
     this.name = \"\";
     this.major = \"\";
     this.gpa = 0;
  }
  // parameterized constructor
  public Student(String id, String name, String major,double gpa) {
     this.id = id;
     this.name = name;
     this.major = major;
     this.gpa = gpa;
  }
  // getter and setter
  public String getId() {
     return id;
  }
  public void setId(String id) {
     this.id = id;
  }
  public String getName() {
     return name;
  }
  public void setName(String name) {
     this.name = name;
  }
  public String getMajor() {
     return major;
  }
  public void setMajor(String major) {
     this.major = major;
  }
  public double getGpa() {
     return gpa;
  }
  public void setGpa(double gpa) {
     this.gpa = gpa;
  }
  // print student data
  public void printStudent() {
     System.out.println(\"Student ID:\" + id);
     System.out.println(\"Student name: \"+ name);
     System.out.println(\"Student major:\" + major);
     System.out.println(\"Student GPA: \"+ gpa);
  }
}
/**************************StudentApplication.java*******************/
public class StudentApplication {
  public static void main(String[] args) {
    Â
     //create object by defaultconstructor
     Student s1 = new Student();
     //create object by overloadedconstructor
     Student s2 = new Student(\"S12345\",\"Virat Kohli\", \"Computer Science\", 4.5);
     //set the information of object1
     s1.setName(\"John Doe\");
     s1.setId(\"S123456\");
     s1.setMajor(\"Electronics\");
     s1.setGpa(4.0);
    Â
     s1.printStudent();
     System.out.println();
     s2.printStudent();
  }
}