CSE 142 Spring 2000 Homework 2



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...

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)

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:

  1. Weights for homework, midterm, and final exam scores.  These integer values should all be between 0 and 100, and their sum should be 100.
  2. 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.
  3. 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.
  4. Next, the 4 integer homework scores.  All should be between 0 and the maximum homework score.
  5. Midterm exam score (int), between 0 and the maximum score for the midterm.
  6. 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
    1. The final score is >= HiCutoff.  Then the grade is 4.0.
    2. The final Score is < LoCutoff.  Then the grade is 0.0.
    3. 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:

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


A few bits of advice

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...