Question: Figure 3.8 in the textbook provides code that allows a user to enter a list of grades in number format, and then it displays the

Figure 3.8 in the textbook provides code that allows a user to enter a

list of grades in number format, and then it displays the letter grade for the number and calculates the

average grade for the class. Modify this code so that it becomes a GPA calculator. You will find the

nested if..else if code example in the textbook on page 78 that also uses numerical grades to be very

useful. Merge the two code examples of the textbook, adding some prompts for the amount of

semester hours per grade, and some variables to keep up with total GPA points earned and total

semester hours taken. Use the following chart of GPA point values:

Number Grade Letter Grade GPA Points per Semester Hour

93-100 A 4.00

90-92 A+ 3.75

86-89 B+ 3.25

83-85 B 3.00

80-82 B- 2.75

76-79 C+ 2.25

73-75 C 2.00

70-72 C- 1.75

66-69 D+ 1.25

63-66 D 1.00

60-62 D- 0.75

< 60 F 0.00

Example: If you enrolled in 13 credit hours (three 3-hour courses and one 4-hour course), and earned a B, a C, anA in the 3 hour courses, and a C- in the 4 hour course this is how you would calculate your total grade points:

Grade 94,

A = 4 points X 3 credit hours = 12 grade points

(Add 12 to totalGPAPopints, and 3 to

totalSemesterHours)

Grade 85,

B = 3 points X 3 credit hours = 9 grade points

Grade 73,

C = 2 points X 3 credit hours = 6 grade points

Grade 70,

C- = 1.75 points X 4 credit hours = 7 grade points

Giving

totals of 13 credit hours 34 grade points

.

From the example above: Divide 34 grade points by the 13

credit hours to equal 2.615 GPA.

Note:

This may seem like a challenging problem, but there is very little that needs to be added to the code presented in the book. Add the If..else if statement mentioned in the textbook to the body of the while clause. Add additional else ifstatements for the additional rows of the table. Add some variables to keep up with the total semester points and total grade points earned for each grade( add to the totals after the statements puts("A"). Calculate and print the GPA.

Sample Inputs and Outputs:

Enter grade, -1 to end: 94

Enter the semester hours for this course: 3

A

Cumulative Semester Hours: 3 Cumulative GPA Points 12.000

Enter grade, -1 to end: 85

Enter the semester hours for this course: 3

B

Cumulative Semester Hours: 6 Cumulative GPA Points 21.000

Enter grade, -1 to end: 73

Enter the semester hours for this course: 3

C

Cumulative Semester Hours: 9 Cumulative GPA Points 27.000

Enter grade, -1 to end: 70

Enter the semester hours for this course: 4

C-

Cumulative Semester Hours: 13 Cumulative GPA Points 34.000

Enter grade, -1 to end: -1

GPA is 2.615

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!