Question: In this assignment you will be creating a GPA calculator. The computer should ask the user to enter a base grade, if it is +/-,
In this assignment you will be creating a GPA calculator. The computer should ask the user to enter a base grade, if it is +/-, and the credits associated with 4 different classes. It should then compute your quarter GPA and display it. Sample interaction should look like the following:
Enter letter(A,B,C,D,F) grade for course 0: B Plus(+), Minus(-) or Straight(x): + Credits: 4 Enter letter(A,B,C,D,F) grade for course 1: A Plus(+), Minus(-) or Straight(x): - Credits: 3 Enter letter(A,B,C,D,F) grade for course 2: B Plus(+), Minus(-) or Straight(x): x Credits: 3 Enter letter(A,B,C,D,F) grade for course 3: C Plus(+), Minus(-) or Straight(x): + Credits: 2 GPA: 3.16666
It is best to build this in stages. The first stage should be to get the grade, plus/minus character, and credits from the user for a single course. Make sure you do this for a single course only at this stage. You will use a loop to do it for 4 courses later.
Once you have the two chars and one int from the user, you need to use the determine their number grade. Do this in 2 stages. First use the letter grade to determine the base number grade. A is 4, B is 3, C is 2, D is 1, and F is 0. Do some printouts to test and make sure your code is working for this stage.
Next you will modify this base number grade by using the +/-/x information. A plus will ad 0.3333, a minus will subtract 0.3333 and straight (x) will not change the base number grade. Please do not have 15 different if cases for A+,A,A-,B+,B,B-,etc. Do it as one set of if/elses for the base letter and a following set for the +/- modifier. In the end this will be less if/else cases and better looking code.
Once you have determined the number grade from the letter and plus/minus, you should multiply it by the number of credits. This will produce the final number grade for this class.
So for example, an A- in a 4 credit class would be: 4 0.3333 --> 3.6667 * 4 --> 14.6668 You should do some more printouts to test your code at this stage. Note that you may have some minor floating-point rounding issues and thus your numbers might be exactly the same as mine past the first few decimal digits.
Lastly you should add the loop that allows you to do it for 4 classes. This should be a simple loop that executes 4 times. Note that you will need to slightly modify the input prompts so the user knows for which class they are currently entering the letter grade (i.e. course 0, 1, 2 or 3). Inside your loop you will not only have the inputs but also the number grade calculations for the current class.
Your loop will need to accumulate the results of all 4 classes. This is similar to the running total examples given in class. You will need to keep a running total of the number grades as well as the total credits. Once all 4 iterations of the loop complete you can simply divide the total number grade by the total credits to get the GPA. For the example above, the total number grade was 37.9999 and the total credits was 12, giving a GPA of 3.16666.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
