[an error occurred while processing this directive]

CMSC201
Programming Project One

Grade Point Average

Out: Tuesday 9/23/97
Due: Midnight Tuesday 10/7/97

The Objective

The objective of this assignment is to make sure that you have learned enough about C and the UNIX system to write a simple program, compile it, run it and turn it in using submit. In particular, it will give you some practice using several data types and will require the use of a while loop that terminates on the input of a sentinel value.

The Explanation

This program will allow you to calculate your GPA for one semester. Some students like to double check their GPA just to make sure the registrar hasn't made any mistakes. :-) After receiving an explanation of the program and entering the semester, the student will be allowed to enter as many courses as he/she sees fit. The program must then calculate and display the GPA earned for that semester.

In order to produce the GPA, several calculations are needed. For each course, the number of credits, multiplied by the grade point earned in that class, results in a value known as quality points. To calculate the GPA, the total number of quality points for the semester is divided by the total number of credits taken that semester, exclusive of credits for courses taken with the Pass/Fail grading method. Your program should NOT handle Pass/Fail courses at all. The only acceptable grade points are in the range of 0 through 4, where 4 is an A, 3 a B, 2 a C, 1 a D, and 0 an F. For this assignment, both the grade points and the number of credits for each course, should be entered as integers and gotten from the user with the GetInteger() function.

To begin you should print a message to the user explaining what the program does. Then you should ask the user to enter the semester. After these initial steps, you should begin asking the user to enter the number of credits and grade points for each course, one course at a time. The user should enter a -1 as the number of credits to end the input phase. So -1 is the sentinel value for this exercise. At this point a report should be generated that shows the total number of credits taken, the total quality points earned, and the GPA for the semester.

Your program must generate all of the same information as shown in the sample run. You do not need to match the output exactly, however the GPA should be shown to three decimal places. You may also use the data shown here to test your program for accuracy.

The Sample Run

umbc9[1]% a.out This program will calculate your GPA for one semester. You will be asked to enter the number of credits and grade points earned for each course taken that was graded using the regular grading method. Please do NOT enter Pass/Fail courses, since they do not effect the GPA. Grade points are 4 for an A, 3 for a B, 2 for a C, 1 for a D, and 0 for an F. Enter semester: Spring 1997 First course: Enter number of credits (-1 to end): 4 Enter grade points: 3 Next course: Enter number of credits (-1 to end): 4 Enter grade points: 4 Next course: Enter number of credits (-1 to end): 3 Enter grade points: 2 Next course: Enter number of credits (-1 to end): 3 Enter grade points: 3 Next course: Enter number of credits (-1 to end): 3 Enter grade points: 2 Next course: Enter number of credits (-1 to end): -1 GPA Report for Spring 1997 Credits taken: 17 Quality points earned: 49 GPA for Spring 1997: 2.882 umbc9[2]%

Submitting the Program

To submit the file you should use the command:

submit cs201 proj1 proj1.c

You can check your submission by using the command:

submitls cs201 proj1 [an error occurred while processing this directive] Monday, 22-Sep-1997 11:44:09 EDT