CMSC104 Fall 2010
Programming Project 1
Out: Tuesday, November 2nd
Due: Tuesday, November 9th, before 11:59 p.m.
- 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.htmland should be in your
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 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:
- 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.
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|
Prompt to get first homework grade
Displaying the average
Displaying the letter grade
- Instead of using alert() statements to display the grade percentage and letter grade, use document.write(). You should produce a nicely formatted grade report that has a heading and displays each individual grade, as well as the percentage and the letter grade. You should add some css to make the report look nicer. The entire output/grade report portion should be written using document.write(). If you decide to do the extra credit, you should only use alert() statements for error checking, not for any other output.
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