CMSC104, Spring 2008
Programming Project 4
Grade Calculator v2.0
Out: Tuesday, May 6, 2008
Due Date: Tuesday, May 13, 2008 before 11:59 p.m.
The Objective
This project is designed to give you practice using arrays in JavaScript.
The Task
You are going to make some improvements to the grade calculator that you designed in Project 1. Rather than storing each of the grades in individual variables, you are going to use arrays to store your data. You should have an array for each of the different types of grades: homeworks, projects and exams. You are also going to error check the user input to make sure the grades are greater than or equal to 0. You should use the GetPositiveValue() function that you created in the functions lab. You should not have to make any changes to GetPositiveValue() in order to use it.
More Details
- You must use for loops when dealing with the arrays (i.e. when you are reading the grades in from the user.)
-
The only function you are required to use is GetPositiveValue(). If
you would like to create and use other functions, you are more
than welcome to do so. The following is a description of the
function from the functions lab:
function GetPositiveValue(promptString)
The function should get a value from the user and error check it to make sure it is greater than or equal to 0. The string passed into the function is the prompt you want to give the user. The function should return the postive value.
Screenshots
- The sample output is the same as the sample output for Project 1.
- If you do not do the extra credit part of the project, your output should match the output from Project 1 exactly. You should not use the screenshots below.
Extra Credit
- You should make your program work such that all of the grades do not have to be entered in order to find the average. In other words, the user can get his or her average at any time in the class, instead of just at the end. You should ask the user how many grades have been completed so far (i.e. How many homeworks are complete?) and then allow them to enter the grades. After getting the homework, project and exam grades, you should display the current average in the class. The screenshots below will show the specific prompts.
Extra Credit Screenshots
Asking for number of homeworks
Getting hw1 from user
Getting hw2 from user
Getting hw3 from user
Asking for number of projects
Getting proj1 from user
Getting proj2 from user
Getting proj3 from user
Asking user for number of exams
Getting exam1 from user
Getting exam2 from user
Displaying current average in course
Displaying current letter grade
Submitting the Program
You do not have to do anything to submit the program. It should be in your pub/www/cs104/proj4 directory.