CMSC104 Fall 2012
Programming Project 1
Grade Calculator
Out: Tuesday, October 23
Due: Wednesday, October 31st, before 11:59 p.m.
The Objective
This project is designed to give you practice writing a C 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 3. 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 have discussed how to print to a specific number of decimal places in class.
- You should use scanf() to get the user's input, and read it into type "int" variables; you should remember the proper format string for doing that. Don't forget the '&' (ampersand) before the variable arguments in the call to scanf()
- The file must be named
proj1.c
Tips and Hints
- Make sure you create the file in the correct directory. You should cd into your cs104/proj1 directory before you create the file.
- Make sure your indentation and your opening and closing curly-braces match up.
- Work incrementally. It is much easier to debug 3-4 lines than it is to debug 40-50 lines. After each increment, make sure the program compiles without errors, and runs.
- Start with the basic elements of every C program: the #include, main(), etc.
- 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 with printf() 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
linux2[14]% gcc -ansi -Wall proj1.c linux2[15]% a.out Welcome to the CMSC104 grade calculation program. This program will calculate the final average and course grade for a student in CMSC104. Each homework is worth 4%, each project is worth 8% and each exam is worth 20%. Enter the homework 1 score: 100 Enter the homework 2 score: 80 Enter the homework 3 score: 100 Enter the homework 4 score: 75 Enter the project 1 score: 75 Enter the project 2 score: 90 Enter the project 3 score: 99 Enter the exam 1 score: 92 Enter the exam 2 score: 80 Enter the exam 3 score: 81 With an average of 85.92, your course grade is a B. Thank you for using the grade calculation program! linux2[16]% a.out Welcome to the CMSC104 grade calculation program. This program will calculate the final average and course grade for a student in CMSC104. Each homework is worth 4%, each project is worth 8% and each exam is worth 20%. Enter the homework 1 score: 100 Enter the homework 2 score: 50 Enter the homework 3 score: 75 Enter the homework 4 score: 95 Enter the project 1 score: 75 Enter the project 2 score: 70 Enter the project 3 score: 75 Enter the exam 1 score: 80 Enter the exam 2 score: 70 Enter the exam 3 score: 65 With an average of 73.40, your course grade is a C. Thank you for using the grade calculation program! linux2[17]%
Submitting the Program
For this assignment, you just submit your source code file,proj1.c
(make sure you use this name).
To submit your project, type the following at the Unix prompt.
Note that the project name starts with uppercase
'P'.