blob: 065bcf369d8af94211a3edf49a3a948c21e598a4 (
plain) (
blame)
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
71
72
73
74
75
76
77
78
79
80
|
// 10.5.cpp : This file contains the 'main' function. Program execution begins and ends there.
// Written by Jacob Knox
//
#include <iostream>
using namespace std;
const int NUM_SCORES = 10;
const int NUM_GRADES = 5;
int main()
{
float scores[NUM_SCORES] = {};
char grades[NUM_SCORES] = {};
int counts[NUM_GRADES] = {0, 0, 0, 0, 0};
float score = 0, tot = 0, avg = 0;
for (int i = 0; i < NUM_SCORES; i++)
{
cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": ";
cin >> score;
scores[i] = score;
tot += score;
if (score >= 90)
{
grades[i] = 'A';
counts[0]++;
}
else if (score >= 80)
{
grades[i] = 'B';
counts[1]++;
}
else if (score >= 70)
{
grades[i] = 'C';
counts[2]++;
}
else if (score >= 60)
{
grades[i] = 'D';
counts[3]++;
}
else
{
grades[i] = 'F';
counts[4]++;
}
}
avg = tot / (float)NUM_SCORES;
for (int i = 0; i < NUM_SCORES; i++)
{
cout << "The " << i + 1 << " student recived a " << scores[i] << "% and got a(n) " << grades[i] << ".\n";
}
cout << "The average score is: " << avg << "%.\n";
char letter;
for (int i = 0; i < NUM_GRADES; i++)
{
if (i != 4)
{
letter = 65 + i;
}
else
{
letter = 70;
}
cout << "There were " << counts[i] << letter << "'s.\n";
}
}
|