CIS071 Lab04 - Convert Numeric Grade to Letter Equivalent DUE: (Noon, Fri, Feb 17, 2006)
Objectives:
Functions with input arguments, and return values. Introduction
to control logic.
Assignment:
Write a program to convert a numeric exam score to its letter grade
equivalent e.g. a grade of 90-100 is ‘A’, 80-89 is ‘B’, 70-79 is 'C', 60-69 is
'D', below 60 is 'F'. The program will:
1) Prompt for and read the user’s numeric grade.
2) Convert the numeric grade to its letter equivalent. If
the value of the numeric grade is out of range (e.g. less than
0 or greater than 100) use the
letter ‘Z’ to indicate an invalid grade.
3) Display a valid numeric grade with a message, such as:
“Your score of 75 is a C grade”
If the grade is not valid display a
message:
“Your score of 105 is not valid”
Use the following functions in your
program:
1. A function that prompts the user for and reads and returns
an exam score. Do not validate the score here.
// Function to prompt for and read a numeric score
// Returns an integer score as read in using scanf
integer getScore( );
2. A
function that converts a numeric score between 0 and 100 to a letter
grade: A, B, ... , F. If the numeric score input to this function
makes no sense, return a value of 'Z'.
// Function to convert a numeric score to a letter grade
// Returns the letter grade
char convertGrade
(int numScore);
// IN: Student exam score
3. A
function to display the original numeric score, the corresponding letter grade
('A' through 'F') if the score is valid, and an appropriate error message if
the score is not valid.
// Function to display a message for valid or invalid grade.
void showGrade
(int
numScore,
// IN: Original student score
char letterGrade);
// IN: Corresponding letter grade
Be sure to test your program for a
range of meaningful values as well as values that are out of range.
Note: There is no logic in function main() -- just calls to the above functions. The functions do all the work. This is how we generally want things done, with the hard work "pushed down" to the lower level functions. You will be downgraded if you do not implement the functions exactly as specified above.
Deliverables:
Submit your program; show a few sample runs of the program.