Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include #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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

Understand the implementation of financial plan recommendations.

Answered: 1 week ago

Question

=+How will this affect the recruiting process?

Answered: 1 week ago