Question
Grade Book (grades.c) Write a menu driven program that simulates a virtual grade book. The program will print a menu of several options. These options
Grade Book (grades.c)
Write a menu driven program that simulates a virtual grade book. The program will
print a menu of several options. These options are: enter grade, nd average, nd
number of certain letter grade, and print the number of total grades entered. Each
function runs and then returns to the main menu except for exit which ends the program,
as per standard procedure the menu is printed inside an innite loop.
For this problem we will use a static xed sized array of 100. You should initialize the
array with a sentinel value `-1' for all 100 positions. When a new grade is entered, it
will replace the sentinel value.
You need to implement the following functions:
void addGrade(int *array, int size);
double average(int *array, int size);
int sum(int *array, int size);
int getSize(int *array);
addGrade: This function gets one new numerical grade from the user and adds it to
the grade book. A valid grade is anything between 0 and 100 inclusive.
average: Average calculates the numerical arithmetic mean of all grades entered and
prints the average value to screen.
sum: This function prompts the user for a letter grade and then calculates how many
entered numerical grades fall into that particular letter grade range; and prints the
count to screen. We will use the standard letter grade bounds for deciding what letter
a given grade corresponds to. The valid choices for letter grades are A, B, C, D, or F.
getSize: This function returns an integer that represents a count of the number of
entered grades. In other words, the returned value should represent the eective size of
the array. To get the count of the entered grades, this function should loop through
the array and check to see which values are not the sentential value (recommended to
use -1, but any invalid input should work that also ts in an int data type). If a value
is not a sentinel value then increase a counter variable until the end of the array. This
counter variable will represent a count of the number of entered grades.
Sample Output:
4
Main menu
1: Add Grade
2: Average Grade
3: Number of a Certain Letter Grade
4: Number of Grades Entered
5: Exit
1
Entered grade: 91
...Print main menu again...
3
Enter a letter grade to find its total count: D
3
...Print main menu again...
4
Number of total grades entered: 4
...Print main menu again...
5
Note: the line ...print main menu again... does not mean to print that literal phrase, it
means to print the menu again and is used here to save space.
Data Type Requirement: Input data is int for the menu, int for the grades in the
array, and char for letter grade choice
Input Validation: Valid menu choices are 1-5, valid grades are between 0 and 100
inclusive.
REMEMBER: This program uses STATIC xed sized arrays.
You have to submit the following le containing the solution of this program
via handin: grades.c
If you could explain that would be great thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started