CMSC104 Fall 2007
Programming Project 1
Grade Calculator
Out: Thursday, November 1
Due: Thursday, November 8 before 11:59 p.m.
The Objective
This project is designed to give you practice writing a JavaScript program on your own. You will also gain experience taking pseudocode you have written and writing the corresponding code. You should practice the incremental programming technique we discussed in class.
The Task
- Your job is to write a grade calculating program for CMSC104.
You should use the pseudocode portion of your answer for question 2
of Homework 2. As in the pseudocode,
you DO NOT have to do any error checking of user input. In addition
to printing the average, you should also determine the letter grade that
corresponds to the numerical average based on the following scale:
90% <= A <= 100% 80% <= B < 90% 70% <= C < 80% 60% <= D < 70% 0% <= F < 60%
- When figuring the letter grade, you should give the next highest grade if the decimal portion is .5 and above. For example, an average of 89.51 is an A.
- You should print the average to two decimal places. We will discuss how to print to a specific number of decimal places in class.
- You may choose to display the output using document.write() or alert(). If you use document.write() and produce a nicely formatted grade report, it is possible to receive extra credit. Your report should include a list of all of the grades entered, as well as the average and letter grade.
- You should use parseInt() to convert each of the grades read in from the user. You can assume that the user will enter grades that are whole numbers (with no decimal portion) greater than or equal to 0. It is possible to have a grade greater than 100.
- The file must be named
proj1.html
and should be in yourpub/www/cs104/proj1
directory.
Tips and Hints
- Your grader will be viewing your page in Firefox so you want to use Firefox when viewing and testing your page.
- Make sure you create the file in the correct directory. You should
cd into your pub/www/cs104/proj1 directory before you create the file. You
can do this by typing (
cd ../pub/www/cs104/proj1
) if you are in your home directory. Check to make sure you are there by typingpwd
. Then, you can create the file by typingxemacs proj1.html
. You should remove all of the default tags that xemacs adds to the file (like we did for Homework 3.) Remember that Ctrl-k will allow you to delete a whole line quickly. - Work incrementally. It is much easier to debug 3-4 lines than it is to debug 40-50 lines. Make sure you close every tag you open as you are working in increments. After each increment, make sure the page works by refreshing your browser. Here is a suggested order:
- Work on the html surrounding the JavaScript first. Add the DOCTYPE, html, head, title and body tags.
- Add the script and the comment tags that go inside of the script tags.
- Add the variable declarations.
- Start adding the rest of the code, only doing 2-4 lines at a time. You might want to prompt the user for the first variable and then display the value in an alert to make sure you read it in correctly.
- You should test your program with other sets of numbers to make sure you get the correct average for multiple sets of input.
Sample Output
The sample screenshots were produced with the following grades as input:
Homework 1: 100 | Project 1: 75 | Exam 1: 92 |
Homework 2: 80 | Project 2: 90 | Exam 2: 80 |
Homework 3:100 | Project 3: 99 | Exam 3: 81 |
Project 4: 100 |
Screenshots
Prompt to get first homework grade
Displaying the average
Displaying the letter grade
Submitting the Program
You do not have to do anything (such as email me) to submit the program. The grader will view your Web page to grade the project. You may not edit your page after 11:59 p.m on the due date. You project will not be accepted if it is modified after the due date