CSE 142 Spring 2000 Homework 2
- assigned Monday, April 17, 2000
- due:
- web submission by 10:00 pm, Sunday, April 23, 2000
- paper submission in lecture Monday, April 24, 2000, or in the homework
drop box on the first floor of Sieg by 1:00 pm, Monday, April 24.
Introduction
After your success with the order entry program for the local computer store,
one of your professors has contracted with you to write a program to calculate
course grades. For this assignment, you should create a program that reads
weights, cutoffs, maximum scores, and the scores for a single student and prints
the student's final grade.
Disclaimer: The rules for calculating grades are similar to those used to
calculate grades for CSE142 and CSE143 but they are not the same.
So don't expect to be able to use this program to calculate your final grade in
this course.
Key Concepts
In this homework, keep an eye out for...
- use of conditional statements,
- design, declaration, and use of functions,
- error checking for input, and
- concepts from previous assignments
Specifications
The program should calculate final grades for a course with 4 homework
assignments, a midterm, and a final exam. These scores are combined to
produce a final score, then this score is converted to a grade on the usual UW
0.0-4.0 scale. The lowest homework score is dropped from the
calculation.
The program should also read the following numbers that enter into the grade
calculation (details of this below)
- Percentage weights given to homework, the midterm, and the final in
calculating the student's score.
- Maximum possible score for each homework assignment (all assignments have the same
maximum score)
- Maximum possible scores for the midterm and final exams
- Minimum score for a passing grade of 0.7
- Minimum score to guarantee a grade of 4.0
The program also should check that input operations succeed (i.e., scanf
returns a value indicating that it has read input values successfully), and
should check that the input is reasonable. All homework and exam scores
and percentage weights are integer quantities. The calculated final score,
minimum cutoffs for passing and perfect grades, and the final grade are all double
(floating-point) quantities.
Your program should run just like the sample executable we have provided on
the web. The computed numbers should be exactly the same. The spacing in the
output doesn't have to be identical, but the order of
the inputs and outputs and your computed numbers must match
exactly. (Remember that this helps your TA, who has to look at many programs,
and you do want your TA to be happy when she/he is grading assignments.)
Input Details
The input to the program should consist of the following data in this
order:
- Weights for homework, midterm, and final exam scores. These integer
values should all be between 0 and 100, and their sum should be 100.
- Maximum score for one assignment (all assignments have the same maximum
score), the midterm, and the
final. Each of these numbers should be an integer in the range 0 to
1000.
- Minimum passing score and minimum score to guarantee a 4.0. Both are
doubles, and the passing score must be less than the 4.0 cutoff.
- Next, the 4 integer homework scores. All should be between 0 and the maximum
homework score.
- Midterm exam score (int), between 0 and the maximum score for the midterm.
- Final exam score(int), between 0 and the maximum score for the final.
Detailed Grade Calculation
Grades are calculated as follows. The basic idea is to convert
the homework and exam scores to numbers between 0.0 and 1.0. This is done by dividing the raw
score by the maximum possible score. Then these normalized scores are
multiplied by the appropriate weights for assignments, the midterm, and final,
and added together to get a final score. This score is converted to a
final grade between 0.7 and 4.0 by interpolating the calculated score in the
range given by the minimum passing and minimum perfect grade cutoffs.
Details:
- Normalized homework score: Add up the homework scores, drop the
lowest score, and divide by 3 (the number of assignments - 1) times the
maximum possible score for any one assignment (i.e., divide the sum of the
three highest scores by the max possible score if all three assignments had
been perfect). That
should give you a normalized homework score between 0.0 and 1.0.
- Exams: Divide each exam score by the maximum possible score on that exam
to get a pair of numbers between 0.0 and 1.0.
- Final score: Multiply each of the normalized scores (homework,
midterm, and final) by the appropriate weight read from the input, and add
these products together. This should give you a final score between 0.0 and 100.0.
- Grade: Let's call the minimum score needed for a passing grade of
0.7 LoCutoff, and the minimum score that guarantees a 4.0 HiCutoff. We've got three cases.
- The final score is >= HiCutoff. Then the grade is 4.0.
- The final Score is < LoCutoff. Then the grade is 0.0.
- The final score is >= LoCutoff but < HiCutoff. Then the
grade is calculated as follows:
grade = 0.7 + (final_score - LoCutoff) / (HiCutoff - LoCutoff)
* scalefactor
rounded to the nearest 0.1. The constant scalefactor is the difference between the lowest and highest
possible grades, i.e., 4.0 - 0.7 = 3.3.
Note: Because of rounding, it is possible for a score below HiCutoff to
still receive a grade of 4.0. If the calculated grade is 3.95 or
higher, it will round up to 4.0. That's ok (the student probably won't
object).
Programming Requirements
One of the key concepts you should exercise in this assignment is appropriate
use of functions. Some operations need to be performed several times
(verifying that input is successful and that the input has a sensible value is
one fairly obvious example). Other operations are sufficiently complex or
subtle that it makes sense to define them as a function. That isolates the
details of the operation in a separate part of the code instead of embedding it
in in the main program. The grade calculation is an example of this.
You should define appropriate functions in your program and use them as
needed. Use your best judgement here. You shouldn't define a tiny
function for every separate calculation in the program, but you should use
functions to break up the program into understandable chunks of code, each one
of which does a single, self-contained operation.
Beside the specific requirement of using functions appropriately, your code
should be clean and understandable as always. Remember to:
- Include appropriate heading comments with every function definition.
It should be possible to understand how to use a function and what it does
without looking at any of the code in the function body.
- Remember to include comments with declarations of important variables to
describe the values in those variables.
- Use
#define
to give meaningful names to significant
constants.
- Stop the program with a meaningful error message if an input operation
fails, or a value is out of range, or if another input error is
detected. You can use conditional (
if
) statements to
check for errors, and use assert(0)
to terminate the program
after printing an error message. Experiment with the sample program to
get an idea of what should happen.
- Be sure to use
int
and double
(floating-point)
variables appropriately in your program.
- Be sure that your program reads input and produces output in the same
order as the sample program.
Submission Guidelines
The due date for this assignment is at the top of
this page. Be especially aware of the web
submission deadline, as submission times are tracked
precisely and we do not accept late submissions.
Files
- self-extracting archive, including starter C file
- hw2_orig.c
- starter C file alone (useful for other C programming environments)
- hw2.exe
- sample executable
A few bits of advice
- Start early. Despite the fact that it improves your life
immensely, so many people ignore this advice. It always
pays to get an early start.
- Read these instructions completely and carefully.
- Try running the sample executable with various input values.
- Before writing a single line of code, plan your solution on
paper. Try thinking about what you would do to perform the
computations yourself.
- Develop and test the program a bit at a time. Don't
try to write the whole program and test it all at once.
- Before turning in your work, test it thoroughly, comparing
results with the sample executable.
- Start right now!
Announcements
If any clarifications or changes need to be made for this
homework, they will be posted to the cse142-announce email list and
linked here.
Return to main Homework page...