I n a collection of exam scores ranging in value from 0 to 100. Your program sho
ID: 3544513 • Letter: I
Question
In a collection of exam scores ranging in value from 0 to 100. Your program should display the category of each score. It should also count and display the number of outstanding scores (90 to 100), the number of satisfactory scores (60 to 89), and the number of unsatisfactory scores (0 to 59). Your program should display the average score at the end of the run. Your program should ensure that each score is valid (in the range 0 to 100).
#include <stdio.h>
int main()
{
int N;
printf("Enter the number of scores ");
scanf("%d",&N);
int array[N];
int i;
for(i=0;i<N;i++)
{
scanf("%d",&array[i]);
if(array[i]<0 || array[i]>100)
{
printf("Invalid score, please enter a valid score ");
i--;
continue;
}
else
{
if(array[i]>=90 && array[i]<=100)
{
printf("Outstanding ");
}
else if(array[i]>=60 && array[i]<=89)
{
printf("Satisfactory ");
}
else if(array[i]>=0 && array[i]<=59)
{
printf("Unsatisfactory ");
}
}
}
return 0;
}
Program Inputs:
Program Outputs:
Program Algorithm:
Program Test Plan:
Program Test Results:
Functions
(Repeat this section for each of your functions).Provide the function prototype here.
Function Analysis:
Function Preconditions and Post Conditions:
Function Inputs and Outputs:
Function formulas:
Function Algorithm:
Explanation / Answer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream> #include <iomanip> using namespace std; void displayGrade(int); void outstanding (int); void satisfactory (int); void unsatisfactory (int); int main() { const int SENTINEL = -99; int score, sum = 0, count = 0, outstanding = 0, satisfactory = 0, unsatisfactory =0; double average; cout <<"Assignment 16 by " << endl << endl; cout << "Enter scores one at a time as requested." << endl; cout << "When done, enter " << SENTINEL << " to finish entering scores." << endl; cout << "Enter the first score: "; cin >> score; while (score != SENTINEL) { sum += score; count++; displayGrade(score); cout << endl<< "Enter the next score: "; cin >> score; if (score >= 90) { outstanding = score >= 90; outstanding++; } else if (score >=60){ satisfactory = score >= 60; satisfactory++; } else { unsatisfactory =score <=59; unsatisfactory++; } } cout << endl << endl; cout << "Number of scores processed is " << count << endl; cout << "Sum of exam scores is " << sum << endl; cout << "The number of Outstanding scores is: " << outstanding << endl; cout << "The number of Satisfactory scores is: " << satisfactory << endl; cout << "The number of Unsatisfactory scores is: " << unsatisfactory << endl; if (count > 0) { average = sum / count; cout << "Average score is " << average << endl; } return 0; } void displayGrade(int score) { if (score >= 90) cout << "Grade is A" << endl; else if (score >= 80) cout << "Grade is B" << endl; else if (score >= 70) cout << "Grade is C" << endl; else if (score >= 60) cout << "Grade is D" << endl; else cout << "Grade is F" << endl; } Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.