Question: 5 4 . 9 Project: Calculate Weighted GPA Write a program that prompts the user for the letter grades and associated credit hours for four
Project: Calculate Weighted GPA
Write a program that prompts the user for the letter grades and associated credit hours for four classes and output the weighted GPA. The number of credit hours is an integer. In order to convert the letter grade to its GPA form, use the code from the LetterToGPA lab. You will need to use the if statement that you developed to convert the letter grade to GPA only and not the one used for checking valid input. We are not checking for invalid input in this project. As the user enters grades and credit hours for four courses, you will want to keep a running sum of GPA and the total number of credit hours to compute the weighted GPA as per the formula below:
Letter Grade Grade's Numerical Value
A
A
B
B
B
C
C
C
D
D
E
This formula essentially means that for each class, you take a grade as input each letter grade will have a corresponding GPA that you need to associate with it and multiply the GPA by the class's credit hours. For instance, if you input A and the calculation would be x which would yield
Let's take a look at an example below with the following course grades and credit hours as input:
Sample Example:
Grade Credits
A
B
B
C
Since we only take four classes as input, we do four different multiplications, sum their results, and divide by the total number of credits hours provided as input.
Step :
We will compute each multiplication of GPA and credit hour calculation.
st Multiplication Class : Input: A and
Multiplication Result:
nd Multiplication Class : Input: B and
Multiplication Result:
rd Multiplication Class : Input: B and
Multiplication Result:
th Multiplication Class : Input: C and
Multiplication Result:
We will now add these values together to obtain the numerator portion of the formula.
Step :
We will now add these values and divide by the total number of credit hours we have provided as input.
Total Credit Hours:
Step :
We will now divide the numerator by the denominator to obtain our final result for our calculated weighted GPA.
All Steps together Using Formula:
Learning Objective: To use for loops and iterative variable updates.
Sample Outputs: This is a sample transcript of what your program should do Make sure your output looks EXACTLY like the output below, including spacing.
Sample run :
Please insert the letter grades and credit hours for your four classes below once prompted.
Enter a letter grade: A
Enter the associated credit hours:
Enter a letter grade: B
Enter the associated credit hours:
Enter a letter grade: A
Enter the associated credit hours:
Enter a letter grade: B
Enter the associated credit hours:
GPA Credit
Your Final GPA is:
Goodbye!
Sample run :
Please insert the letter grades and credit hours for your four classes below once prompted.
Enter a letter grade: A
Enter the associated credit hours:
Enter a letter grade: B
Enter the associated credit hours:
Enter a letter grade: C
Enter the associated credit hours:
Enter a letter grade: D
Enter the associated credit hours:
GPA Credit
Your Final GPA is:
Goodbye!
Hints:
You will need to write a loop to take in all the classes.
You will want to keep a string variable that holds the table that you want to print, and every time you loop, you will want to add a new table line to the end of that string. You can start a new line with the character
We also use tabs instead of spaces in our table, which can be added by writing t in your string.
Start with a GPA and add on the weighted GPA for each class.
You can then divide by the total credit hours at the end of your while loop to get the weighted GPA. When you do this, try multiplying the summed weighted GPA by in order to switch to a floating point division instead of an integer division.
qxzqy
lab activity
: Project: Calculate Weighted GPA
DESCRIPTION OF PROGRAM HERE
@author YOUR NAME HERE
@version DATE HERE
import java.util.Scanner;
public class LetterToGPA
public static void mainString args
Scanner input new ScannerSystemin;
Type your code here.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
