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

Write an application that enables a user to input the grade and number of credit

ID: 3671239 • Letter: W

Question

Write an application that enables a user to input the grade and number of credit hours for any number of courses. Calculate the GPA on a 4.0 scale using those values. Grade point average (GPA) is calculated by dividing the total amount of grade points earned, sometimes referred to as quality points, by the total number of credit hours attempted. For each hour, an A receives 4 grade or quality points, a B receives 3 points, a C receives 2 points, and a D receives 1 point. Thus, a three–credit hour course receiving an A would have 12 quality points associated with the course. Allow the user to input any number of courses and associated grades. Display the number of hours earned and the calculated GPA. Grade: no class 100, with a class (GPAclass) 150

Explanation / Answer


public class Student
{
  
   // Variables field
   private int idNum;
   private float creditHoursNum;
   private float earnedPointsNum;
   private float gpa;
  
   //note: this constructor is used from the instance of the object named
   //studentObject in the Student class
   public Student()
   {
       idNum = 9999;
       creditHoursNum = 3;
       earnedPointsNum = 12;
      
   }  

   // this method sets the value of idNum field
   public void setIdNum(int idNum)
   {
       this.idNum = idNum;
      
   }
   // this method sets the value of CreditHoursNum field
   public void setCreditHoursNum(float creditHoursNum)
   {
       this.creditHoursNum = creditHoursNum;
   }
   // this method sets the value of earnedPoints field
   public void setEarnedPointsNum(float earnedPointsNum)
   {
       this.earnedPointsNum = earnedPointsNum;
   }
  
   // This method sets the value of gpa field
   public void setGpa (float earnedPointsNum, float creditHoursNum)
   {
       gpa = earnedPointsNum / creditHoursNum;
      
   }
  
   // This method gets the data in the idNum field
   public int getIdNum()
   {
       return idNum;
   }
   // This method gets the data in the CreditHours field
   public float getCreditHoursNum()
   {
       return creditHoursNum;
   }
  
   //This method gets the data in the earnPointsNum Field
   public float getEarnedPointsNum()
   {
       return earnedPointsNum;
   }
  
   //This method gets the data from the gpa field
   public float getGpa ()
   {
      
       return gpa;
   }
      
      
}


ShowStudent.java

import java.util.Scanner;

public class ShowStudent
{
   public static void main(String[] args)
   {
   //Variable Definition
       float creditHours;
       float pointsEarned;
       int idNumber;
      
   // Instantiate a student object
       Student studentObject = new Student();
      
   //Create the Scanner object
       @SuppressWarnings("resource")
       Scanner keyboard = new Scanner(System.in);
      
   //Prompt the user for the id number and credit hours and points earned
       System.out.println("Enter your student ID number.");
       idNumber = keyboard.nextInt();
       System.out.println("Enter the amount of credit hours earned.");
           creditHours = keyboard.nextFloat();
       System.out.println("Enter the amount of points earned.");
           pointsEarned = keyboard.nextFloat();
      
      
          
   //Use the setGpa method() from the Student class and input values into the field
       studentObject.setGpa( pointsEarned, creditHours);
   //Use the setIdNum() method from the Student class and input value into the field
       studentObject.setIdNum(idNumber);
   //Use the setCreditHoursNum from the Student class and input value into the field
       studentObject.setCreditHoursNum(creditHours);
   //Use the setCreditHoursNum from the Student class and input value into the field
       studentObject.setEarnedPointsNum(pointsEarned);
              
      
  
   // Display the student information
       System.out.println("Your ID # is:");
       System.out.println(studentObject.getIdNum());
       System.out.println("Your course hours earned is:");
       System.out.println(studentObject.getCreditHoursNum());
       System.out.println("Your points earned is:");
       System.out.println(studentObject.getEarnedPointsNum());
       System.out.println("Your GPA is:");
       System.out.println(studentObject.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