-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrade Processing
70 lines (60 loc) · 1.45 KB
/
Grade Processing
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
70
// S112 Kowata Grade Processing.cpp
// Author: Michael Kowata
// Goal: Read and validate data items representing grades. Terminate when the user indicates there is no more data to be read.
// Calculates Average, Max, Min, Count
#include <iostream>
using namespace std;
int main()
{
//Variable Declaration
int grade, count=0, max=-1, min=101;
int sum = 0;
double average;
char yesNoAnswer='y';
//Input
while (yesNoAnswer=='y')
{
do
{
cout << "\nEnter a grade (0...100): ";
cin >> grade;
if (grade < 0 or grade>100)
{
cout << "Invalid grade - Try again\n";
}
else
{
break;
}
} while (true);
count++;
sum += grade;
do
{
cout << "Do you want to continue? (y/n) ";
cin >> yesNoAnswer;
if (yesNoAnswer == 'Y' or yesNoAnswer == 'N')
{
break;
}
} while (true);
}
count++;
sum == grade;
if (grade > max);
{
max = grade;
}
if (grade < min);
{
min = grade;
}
//Process
average = sum / count;
//Output
cout << "Total grades: " << count << endl;
cout << "Average grade: " << average << endl;
cout << "Max grade: " << max << endl;
cout << "Min grade: " << min << endl;
cout << "\nall done\n";
}