Starting from:

$30

CSCI160 Computer Science I  Program 5a -Solved


In this lab we will ask the user for information about the classes they are taking this semester, 
and then determine their grade point average (GPA) for that semester. To determine a student’s 
GPA, you divide the number of honor points by the number of attempted (not passed) credits. 
To determine honor points, for each class multiple the number of credits by the grade’s honor 
points; 4 for an A, 3 for a B, 2 for a C, 1 for a D, or 0 for an F. This program will ignore grades of 
pass, fail, or incomplete. 
The program will ask the user for the number of classes they are taking this semester. For each 
class, ask for the name of the class, the number of credits and the letter grade. DO NOT ask for 
honor points for each class, that will be determined from the letter grade. Continue to ask for 
this information for each class. No error checking of the data is required; you can safely assume 
all data entered will be valid. 
For example, if you received a 4 credit A and a 3 credit B in a semester, this is how you 
determine the honor points: 
4 (credits) * 4 (determined from the entered A) = 16 
3 (credits) * 3 (determined from the entered B) = 9 
This input would result in 25 honor points / 7 attempted credits = 3.571429, which would be 
truncated in the output to 3.5714. 
Requirements/Assumptions 
You can safely assume that no grade other than A, B, C, D, or F will be entered. 
The grade MUST be entered as a letter grade; it cannot be entered as a number. 
You can assume that the grade will be entered as an upper-case letter. 
If the GPA cannot be calculated do not generate any output, just end the program. 
Output 
Once the user is done entering their classes, print out the following: 
Grade point average, with 4 places after the decimal point 
Number of credits attempts 
Number of credits passed (any grade other than an F) 
Number of classes attempted 
Number of classes passed (any grade other than an F) 
Ensure that the final output it in table format, using aligned columns with the text left justified 
and all the numbers right justified.Sample output (this is typed, not captured from a run) 
An example of running the program might be: 
Enter the number of classes this semester: 2 
Enter a class: CS160 
Enter the number of credits: 4 
Enter your grade: A 
Enter the next class: Math 208 
Enter the number of credits: 3 
Enter your grade: B 
GPA: 3.5714 
Credits attempts 7 
Credits passed 7 
Classes attempted 2 
Classes passed 2

More products