• Assignment

## Assignment

You are to write a program that will calculate a student’s quiz average. The program should prompt the user for the number of quizzes and then ask the user for each quiz grade. If the user enters a quiz grade of less than 0 or greater than 100 the user should be prompted to enter that quiz grade again. Once all of the quiz grades are entered by the user, the quiz grades should be used to compute the user’s quiz average.
After the quiz average is calculated, the quiz average should be displayed to the user along with the letter grade.

Greater than or equal to 90 A
Greater than or equal to 80 B
Greater than or equal to 70 C
Greater than or equal to 60 D
Otherwise F
The input prompts and output statements must match the sample execution below.

Sample Executions:

Quiz Calculator
How many quizzes: 4
Your quiz average is 90.500000, A
Quiz Calculator
How many quizzes: 2
Your quiz average is 80.000000, B

Sample Executions:
Quiz Calculator
How many quizzes: 3
I think you made a mistake!
I think you made a mistake!
Your quiz average is 48.333332, F

Solution

netIDprog4.c

#include

int main() {

int quizzes; //to store total quiz

floattotalScore = 0.0, score; //toal score and individual score

printf(“How many quizzes: “);

scanf(“%d”, &quizzes);

// for each quiz

for (int i = 1; i <= quizzes; ++i) {

do {

printf(“Enter quiz %d grade: “, i);

scanf(“%f”, &score);

if (score < 0 || score > 100) { //if invalid

printf(“I think you made a mistake!\n\n”);

}

} while (score < 0 || score > 100); //continue while invalid

totalScore += score;

}

//calculate average

float average = totalScore / quizzes;

if (average >= 90)

else if (average >= 80)

else if (average >= 70)

else if (average >= 60)