CMSC104 Fall 2009
Programming Project 3
GPA Calculator
Out: Thursday, November 19,2009
Due Date: Tuesday, December 1, 2009 before 11:59 p.m.
The Objective
This project is designed to give you practice writing your own functions in JavaScript.
The Task
This program will allow you to calculate your GPA for one semester. 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. So, for example, if you took one 4 credit course and received a B, your GPA for that semester would be:
4 credits * 3 points = 12 quality points 12 total quality points / 4 total credits = 3.000 GPA
If there is more than one course, you just keep adding the quality points to the total points and credits to the total credits.
To begin the program , 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 name, number of credits and grade for each course, one course at a time. The user should enter "emd" as the name of the course to end the input phase. So "end" 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 output. 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.
More Details
- You are REQUIRED to use the following functions exactly as they are given:
-
function PrintExplanation(){}
- This function should display a description of the program to the user. You should print the explanation using an alert(). The function should not return anything. -
function GetValidNumberInput(promptString, lowerNum, upperNum){}
- This function takes three arguments: the string that contains the prompt you want to print when prompting the user to enter the credits, the lowerbound for the number, and the upper bound for number. You should ask the user for the number. Then the function should error check to make sure the input is a number between lowerNum and upperNum inclusive. The function should return the valid number. The function should be general and not mention anything about credits. -
function GenerateGradeReport(semester, totalCredits, totalPoints){}
- This function should display the grade report to the user. You should use document.write() to produce the report. You will make a call to the function CalculateGPA() from within this function. The function should not return anything. -
function CalculateGPA(totalCredits, totalPoints){}
- This function simply performs the GPA calcuation. It should return the calculated GPA. -
function ConvertGradeToPoints(grade){}
- This function simply converts a letter grade into its corresponding point value.
-
- You should use the GetValidNumberInput() function to get the number of credits from the user.
- You do not have to error check the grades. You can assume the user will only type A, B, C, D, or F.
- You do not have to error check the course name or the semester. You can assume the user can type.
- An internal style sheet can add up to 5 points extra credit for presentation.
Screenshots
Explanation of program
Getting semester from user
Getting course name from user
Error message for invalid credits
Getting grade from user
Entering sentinel value
Final GPA report
Submitting the Program
You do not have to do anything to submit the program. It should be in your pub/www/cs104/proj3 directory.
Extra Credit
Make the GPA Calculator calculate the user's cummulative GPA. Start by asking the user how many semesters they have been in school and then prompt them to enter information for each semester. The grade report at the end of each semester should show the GPA for the semester and the student's cummulative GPA. Assume that the user will enter the information in chronological order.(10 points)