aboutsummaryrefslogtreecommitdiff
path: root/Lab5_taormina
blob: 829be8e13f3c944b3ab12bf351e3f36a614afad5 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
//Tyler Taormina
//Lab 5 CST 116
//October 2021

LAB 5
________________________________________________________________________________________________________________________
9a
10.5 Learn by Doing Exercises
p 247
10 pts #1
Submit: code & run
CODE:

#include <iostream>
using namespace std;

const int NUM_SCORES = 10;
const int NUM_STUDENTS = 10;


int main()
{
    float currStudent[NUM_SCORES]{0.0};
    char LetterGrades[NUM_SCORES];
    float total = 0.0, average = 0.0;
    int A = 0, B = 0, C = 0, D = 0, F = 0;

    //Read scores
    for (int i = 0; i < NUM_SCORES; i++)
    {
        cout << "Enter Score #" << i + 1 << " of " << NUM_SCORES << ": " << endl;
        cin >> currStudent[i];
    }

    //Letter Grade List
    for (int i = 0; i < NUM_STUDENTS; i++)
    {
        //Letter Grade A
        if (currStudent[i] >= 92.0)
        {
            LetterGrades[i] = char(65);
            A += 1;
        }

        //Letter Grade B
        else if (currStudent[i] < 92.0 && currStudent[i] >= 84.0)
        {
            LetterGrades[i] = char(66);
            B += 1;
        }

        //Letter Grade C
        else if (currStudent[i] < 84.0 && currStudent[i] >= 75.0)
        {
            LetterGrades[i] = char(67);
            C += 1;
        }

        //Letter Grade D
        else if (currStudent[i] < 75.0 && currStudent[i] >= 65.0)
        {
            LetterGrades[i] = char(68);
            D += 1;
        }

        //Letter Grade F
        else
        {
            LetterGrades[i] = char(70); //F
            F += 1;
        }
    }


    //Calculate average score for class
    for (int i = 0; i < NUM_SCORES; i++)
    {
       total += currStudent[i];
    }
    average = total / NUM_STUDENTS;

    //Print Info
    for (int i = 0; i < NUM_SCORES; i++)
    {
        cout << "Student " << i + 1 << " Letter Grade: " << LetterGrades[i];
        cout << " and Score: " << currStudent[i] << endl;
    }

    cout << endl;
    cout << endl;
    cout << "Class Average: " << average << endl;

    cout << "A's: " << A << endl;
    cout << "B's: " << B << endl;
    cout << "C's: " << C << endl;
    cout << "D's: " << D << endl;
    cout << "F's: " << F << endl;

    return 0;
}


RUN:
C:\Users\Till\CLionProjects\gitDemo\cmake-build-debug\gitDemo.exe
Enter Score #1 of 10:
100
Enter Score #2 of 10:
90
Enter Score #3 of 10:
74
Enter Score #4 of 10:
74
Enter Score #5 of 10:
89
Enter Score #6 of 10:
44
Enter Score #7 of 10:
44
Enter Score #8 of 10:
89
Enter Score #9 of 10:
59
Enter Score #10 of 10:
5
Student 1 Letter Grade: A and Score: 100.
Student 2 Letter Grade: B and Score: 90.
Student 3 Letter Grade: D and Score: 74.
Student 4 Letter Grade: D and Score: 74.
Student 5 Letter Grade: B and Score: 89.
Student 6 Letter Grade: F and Score: 44.
Student 7 Letter Grade: F and Score: 44.
Student 8 Letter Grade: B and Score: 89.
Student 9 Letter Grade: F and Score: 59.
Student 10 Letter Grade: F and Score: 5.


Class Average: 66.8
A's: 1
B's: 3
C's: 0
D's: 2
F's: 4

Process finished with exit code 0

________________________________________________________________________________________________________________________
9b
10.6 Learn by Doing Exercises
p 253
Break into 3 files: the main() file, the functions .cpp file and the .h file.
10 pts #1
Submit: code & runs
CODE:

View code in Folder mod_9b. Contains the three files. 

RUN:
t
Enter Score #1 of 10: 
99
Enter Score #2 of 10: 
99
Enter Score #3 of 10: 
99
Enter Score #4 of 10: 
99
Enter Score #5 of 10: 
99
Enter Score #6 of 10: 
99
Enter Score #7 of 10: 
44
Enter Score #8 of 10: 
55 
Enter Score #9 of 10: 
44
Enter Score #10 of 10: 
44
Student 1 Letter Grade: A and Score: 99
Student 2 Letter Grade: A and Score: 99
Student 3 Letter Grade: A and Score: 99
Student 4 Letter Grade: A and Score: 99
Student 5 Letter Grade: A and Score: 99
Student 6 Letter Grade: A and Score: 99
Student 7 Letter Grade: F and Score: 44
Student 8 Letter Grade: F and Score: 55
Student 9 Letter Grade: F and Score: 44
Student 10 Letter Grade: F and Score: 44


Class Average: 78.1
A's: 6
B's: 0
C's: 0
D's: 0
F's: 4


________________________________________________________________________________________________________________________
10a
10.7 Learn by Doing Exercises
p 260
Break into at least 3 files as in 9b.
10 pts #2
Submit: code & runs
CODE:
see folder mod_10a
RUN:
________________________________________________________________________________________________________________________
10b
10.8 Learn by Doing Exercises
p 273
Break into at least 3 files as in 9b.
10 pts #7 Write a full program to do this.
Submit: code & runs
CODE:

see folder mod_10b

RUN: