+1 (812) 783-0640 

How to create a grade calculator

Grade calculators are important tools in institutions of higher learning, as they help keep student marks on track. If you would like help with assignments related to the development of a grade calculator, reach out to us immediately.

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.

Quiz Average 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
Enter quiz 1 grade: 90
Enter quiz 2 grade: 100
Enter quiz 3 grade: 87
Enter quiz 4 grade: 85
Your quiz average is 90.500000, A
Quiz Calculator
How many quizzes: 2
Enter quiz 1 grade: 85
Enter quiz 2 grade: 75
Your quiz average is 80.000000, B

Sample Executions:
Quiz Calculator
How many quizzes: 3
Enter quiz 1 grade: -10
I think you made a mistake!
Enter quiz 1 grade: 10
Enter quiz 2 grade: 195
I think you made a mistake!
Enter quiz 2 grade: 95
Enter quiz 3 grade: 40
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

// read quizzes

printf(“How many quizzes: “);

scanf(“%d”, &quizzes);

// for each quiz

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

do {

// read score

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

// add to toal score

totalScore += score;

}

//calculate average

float average = totalScore / quizzes;

// calculate grade

char grade;

if (average >= 90)

grade = ‘A’;

else if (average >= 80)

grade = ‘B’;

else if (average >= 70)

grade = ‘C’;

else if (average >= 60)

grade = ‘D’;

else

grade = ‘F’;

//rpint result

printf(“Your quiz average is %f, %c”, average, grade);

}