# Programming Project 1

Out: Tuesday, November 2nd

Due: Tuesday, November 9th, 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.

• 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. 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.
• The output should be displayed using alert() statements.
• You should use parseInt() (rather than parseFloat()) to convert each of the grades read in from the user.
• You should do error checking for each grade to make sure that the user does not enter a grade that is less than 0. As we discussed in class, you want to use a while loop (not an if statement) to do the error checking.
• The file must be named `proj1.html` and should be in your `pub/www/cs104/proj1` directory.

## Tips and Hints

• 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 typing `pwd`. Then, you can create the file by typing ```xemacs proj1.html```. You should remove all of the default tags that xemacs adds to the file (like we did for Homework 3 Part 2). 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:

1. Work on the html surrounding the JavaScript first. Add the DOCTYPE, html, head, title and body tags.
2. Add the script and the comment tags that go inside of the script tags.
4. 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 Homework 4: 100

## Screenshots

Prompt to get first homework grade

Displaying the average