Question
Modify the grade book code from Unit 3 so that it uses 3 custom functions to calculate the average grade (arithmetic mean, not letter grade),
Modify the grade book code from Unit 3 so that it uses 3 custom functions to calculate the average grade (arithmetic mean, not letter grade), report the highest grade, and find the lowest grade entered. This version of the program does not need to use heap memory, though you are welcome to do so. The program should allow the user to indicate when he or she is done entering grades (since the user may not have grades to fill the whole array). When the user is done entering grades, the program should print out the grades entered by the user. The program should also display the average grade, highest grade, and lowest grade.
Here is my code from unit 3:
#include
int main() {
char choice; /* choice of user *//* array of scores */ int *gradeScoreArray;/* array of scores */ int gradeScore; /*grade scores defined as an integer */ int count=0; char LetterGrade;/* letter grade defined as a character */
gradeScoreArray = (int *) calloc(50, sizeof(int)); /* allocated space in heap*/
do{ /* Tells the program to do the loop for the case at least one time */ printf("-------------------Please enter your choice--------------- To add grade score(a) To quit(q) "); /* Ask user to select choice (a) or (q) for quit */ scanf(" %c",&choice); /* getting user input */ switch(choice){ int i = 0; case 'a': printf("Please enter the scores between 0 to 100 "); /* Ask user to enter grade scores */ scanf(" %d",&gradeScore); /* getting user input */ gradeScoreArray[count]=gradeScore;/* adding the scores to array */ count++; break;
case 'q':
for (i = 0;i if (gradeScoreArray[i] >= 0 && gradeScoreArray[i] <= 100) { /* conditions for the grade */ if (gradeScoreArray[i] >= 0 && gradeScoreArray[i] < 60) LetterGrade = 'F'; else if (gradeScoreArray[i] >= 60 && gradeScoreArray[i] < 70) LetterGrade = 'D'; else if (gradeScoreArray[i] >= 70 && gradeScoreArray[i] < 80) LetterGrade = 'C'; else if (gradeScoreArray[i] >= 80 && gradeScoreArray[i] < 90) LetterGrade = 'B'; else if (gradeScoreArray[i] >= 90 && gradeScoreArray[i] <= 100) LetterGrade = 'A'; printf(" For a numeric grade of %d, ", gradeScoreArray[i]);/* printing the score */ printf("the corresponding letter grade is %c. ", LetterGrade); /* printing the grade associated with the score */ }else{ printf(" Invalid numeric grade!"); } } break; default: printf("Invalid choice"); } }while(choice!='q'); free(gradeScoreArray); getchar(); /* pause window*/ return 0; }
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