-
Notifications
You must be signed in to change notification settings - Fork 2
/
Grades.cpp
62 lines (56 loc) · 1.69 KB
/
Grades.cpp
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
#include <iostream>
using namespace std;
int main(void)
{
bool exit = false;
do
{
int option;
int grade[10];
const char *names[10] = {"Amir", "Marry", "Ray", "Sara", "Lara", "Kane", "Alex", "Beth", "Martin", "Ali"};
cout << "Select a number:\n 1- Enter grades.\n 2- Change one grade.\n 3- The Report.\n 4- Exit.\nWhat do want to do? ";
cin >> option;
switch (option)
{
case (1):
for (int i = 0; i < 10; i++)
{
cout << i + 1 << "- Enter " << names[i] << " grade: ";
cin >> grade[i];
}
cout << "You have entered 10 grades. Thank you!\n";
break;
case (2):
int number;
cout << "Enter the student number: ";
cin >> number;
cout << "Enter the Grade: ";
cin >> grade[number - 1];
cout << " 1- The grade for " << names[number - 1] << " changed to " << grade[number - 1] << "\n";
break;
case (3):
{
int sum = 0;
int max = 0;
int min = 50;
for (int i = 0; i < 10; i++)
{
sum += grade[i];
if (min > grade[i])
{
min = grade[i];
}
if (max < grade[i])
{
max = grade[i];
}
}
cout << "The average is: " << sum / 10 << "| The Max grade is: " << max << "| The Min grade is: " << min << "\n";
}
break;
case (4):
exit = true;
break;
}
} while (exit == false);
}