Program 2 - GPA

Comp 170

 

 

Write a C++ program that calculates grade point averages according to the rules given below. 

 

Your program should:

1.     Validate input data whenever possible.  For example, your program should not accept invalid data like an E grade or credit hours less than 0 or greater than 6. 

2.     Use constants whenever possible.

3.     Use “good” variable names.

4.     Display the GPA to 2 decimal places, even if it’s a whole number (4.00). 

5.     Allow case insensitive input (“A” or “a” is acceptable).

6.     Allow any number of courses to be entered.

 

Your program should look exactly like the example shown below.  (Except your user input should not be shown in bold.  )

 

_________________________________________________________________________________________

 


 

Number of courses? 3

 

For course 1:

Grade? A

Hours? 4

 

For course 2:

Grade? C

Hours? 2

 

For course 3:

Grade? B

Hours? 3

 

GPA is 3.22

 

________________________________________________________________________________________

 

 

GPA = Total Quality Points / Total Credit Hours

 

Quality Points = Grade Multiplier * Course Credit Hours

 

Grade Multipliers:  A = 4, B = 3, C = 2, D = 1, F = 0