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

Explanation / Answer

The code is given below:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package javaapplication1;

/**

*

* @author miracle

*/

import java.util.Scanner;

public class JavaApplication1

{

public static void main(String[] args) {

Scanner input = new Scanner (System.in);

String name;

int ID;

int tel;

String email;

int subjects;

String subjectName;

int subjectCreditHour=0;

int subjectMark;

String subjectGrade="";

double GradePoint=0;

double subjectGradePoint = 0d;

double CGPA = 0d;

double totalSubjectGP = 0d;

int totalCreditHour = 0;

System.out.print("Please input student's name : ");

name = input.nextLine();

System.out.print("Please input student's ID : ");

ID = input.nextInt();

System.out.print("Please input student's telephone number : ");

tel = input.nextInt();

System.out.print("Please input student's email : ");

email = input.next();

System.out.print("Please input number of subjects : ");

subjects = input.nextInt();

for (int i = 1; i <= subjects ; i++) {

System.out.println("Subject " + i + " : Please input the following");

System.out.print("Subject name : ");

subjectName = input.next();

System.out.print("Credit Hour : ");

subjectCreditHour = input.nextInt();

System.out.print("Mark : ");

subjectMark = input.nextInt();

if ( subjectMark >= 80 ) {

subjectGrade = "A";

GradePoint = 4.0;

} else if (subjectMark < 80) {

subjectGrade = "B+";

GradePoint = 3.5;

} else if (subjectMark < 70) {

subjectGrade = "B";

GradePoint = 3.0;

} else if (subjectMark < 65) {

subjectGrade = "C+";

GradePoint = 2.5;

} else if (subjectMark < 55) {

subjectGrade = "C";

GradePoint = 2.0;

} else if (subjectMark < 50) {

subjectGrade = "D";

GradePoint = 1.0;

} else {

subjectGrade = "F";

GradePoint = 0.0;

}

subjectGradePoint = GradePoint * totalCreditHour;

totalSubjectGP += subjectGradePoint;

totalCreditHour += totalCreditHour;

}

CGPA = totalSubjectGP / totalCreditHour;

System.out.println("Grade = " + subjectGrade);

System.out.println("Subject Grade Point = " + (GradePoint * subjectCreditHour));

System.out.println("Name : " + name);

System.out.println("ID : " + ID);

System.out.println("Tel : " + tel);

System.out.println("email : " + email);

System.out.print("Total subject Grade Points = "+subjectGradePoint );

System.out.print("Total Credit Hours = "+totalCreditHour );

System.out.print("Cumulative Grade Point Average ="+CGPA);

}

}

Hope this helps

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