aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab5/CST116F2021-Lab5.cpp
blob: 64e6b3e223e474911b52deb8e88356601314aeff (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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#include "CST116F2021-Lab5(Header).h"

//9a -
//Section 10.5 -

//int main()
//{
	//create arrays
//	int studentScores[10];
//	char studentGrades[10];
	//loop input into array
//	for (int scoreCount = 0; scoreCount <= 9; scoreCount++)
//	{
//		cout << "Enter student " << scoreCount + 1 << "'s score: ";
//		cin >> studentScores[scoreCount];
//	}
	//scores to grades loop
//	for (int scoreCount = 0; scoreCount <= 9; scoreCount++)
//	{
//		if (studentScores[scoreCount] >= 92.0)
//		{
//			studentGrades[scoreCount] = 'A';
//		}
//		else if (studentScores[scoreCount] >= 84.0)
//		{
//			studentGrades[scoreCount] = 'B';
//		}
//		else if (studentScores[scoreCount] >= 75.0)
//		{
//			studentGrades[scoreCount] = 'C';
//		}
//		else if (studentScores[scoreCount] >= 65.0)
//		{
//			studentGrades[scoreCount] = 'D';
//		}
//		else if (studentScores[scoreCount] < 65.0)
//		{
//			studentGrades[scoreCount] = 'F';
//		}
//	}
	//display grades for each student
//	cout << endl;
//	for (int gradeCount = 0; gradeCount <= 9; gradeCount++)
//	{
//		cout << "Student " << gradeCount + 1 << "'s grade: " << studentGrades[gradeCount] << endl;
//	}
	//display class average
//	cout << endl;
//	float classAverage = 0;
//	for (int scoreCount = 0; scoreCount < 10; scoreCount++)
//	{
//		classAverage = classAverage + studentScores[scoreCount];
//	}
//	cout << "Class average: " << classAverage/10 << endl;
	//display number of students per grade
//	cout << endl;
//	int studentAs = 0;
//	int studentBs = 0;
//	int studentCs = 0;
//	int studentDs = 0;
//	int studentFs = 0;

//	for (int gradeCount = 0; gradeCount < 10; gradeCount++)
//	{
//		if (studentGrades[gradeCount] == 'A')
//		{
//			studentAs++;
//		}
//		if (studentGrades[gradeCount] == 'B')
//		{
//			studentBs++;
//		}
//		if (studentGrades[gradeCount] == 'C')
//		{
//			studentCs++;
//		}
//		if (studentGrades[gradeCount] == 'D')
//		{
//			studentDs++;
//		}
//		if (studentGrades[gradeCount] == 'F')
//		{
//			studentFs++;
//		}
//	}

//	cout << studentAs << " students got A's" << endl;
//	cout << studentBs << " students got B's" << endl;
//	cout << studentCs << " students got C's" << endl;
//	cout << studentDs << " students got D's" << endl;
//	cout << studentFs << " students got F's" << endl;
//}

//9b -
//Section 10.6

//Function Prototypes
//void getScores(int studentScores[]);
//void calculateGrades(int studentScores[], char studentGrades[]);
//void displayGrades(char studentGrades[]);
//void classAverage(int studentScores[]);
//void studentsPerGrade(char studentGrades[]);

//int main()
//{
	//defining
//	int studentScores[10];
//	char studentGrades[10];
	//entry sequence
//	cout << "Welcome to the 10 scores to grades program." << endl;
	//get scores
//	cout << endl;
//	getScores(studentScores);
	//calculate grades
//	calculateGrades(studentScores, studentGrades);
	//display grades
//	cout << endl;
//	displayGrades(studentGrades);
	//display class average
//	cout << endl;
//	classAverage(studentScores);
	//display students per grade
//	cout << endl;
//	studentsPerGrade(studentGrades);

//	return 0;
//}

//void getScores(int studentScores[])
//{
//	for (int scoreCount = 0; scoreCount < 10; scoreCount++)
//	{
//		cout << "Please enter student " << scoreCount + 1 << "'s score: ";
//		cin >> studentScores[scoreCount];
//	}
//}

//void calculateGrades(int studentScores[], char studentGrades[])
//{
//	for (int scoreCount = 0; scoreCount < 10; scoreCount++)
//	{
//		if (studentScores[scoreCount] >= 92.0)
//		{
//			studentGrades[scoreCount] = 'A';
//		}
//		else if (studentScores[scoreCount] >= 84.0)
//		{
//			studentGrades[scoreCount] = 'B';
//		}
//		else if (studentScores[scoreCount] >= 75.0)
//		{
//			studentGrades[scoreCount] = 'C';
//		}
//		else if (studentScores[scoreCount] >= 65.0)
//		{
//			studentGrades[scoreCount] = 'D';
//		}
//		else if (studentScores[scoreCount] < 65.0)
//		{
//			studentGrades[scoreCount] = 'F';
//		}
//	}
//}

//void displayGrades(char studentGrades[])
//{
//	for (int gradeCount = 0; gradeCount < 10; gradeCount++)
//	{
//		cout << "Student " << gradeCount + 1 << "'s final grade: " << studentGrades[gradeCount] << endl;
//	}
//}

//void classAverage(int studentScores[])
//{
//	float classAverage = 0;
//	for (int scoreCount = 0; scoreCount < 10; scoreCount++)
//	{
//		classAverage = classAverage + studentScores[scoreCount];
//	}
//	cout << "Class average: " << classAverage / 10 << endl;
//}

//void studentsPerGrade(char studentGrades[])
//{
//	int studentAs = 0;
//	int studentBs = 0;
//	int studentCs = 0;
//	int studentDs = 0;
//	int studentFs = 0;

//	for (int gradeCount = 0; gradeCount < 10; gradeCount++)
//	{
//		if (studentGrades[gradeCount] == 'A')
//		{
//			studentAs++;
//		}
//		if (studentGrades[gradeCount] == 'B')
//		{
//			studentBs++;
//		}
//		if (studentGrades[gradeCount] == 'C')
//		{
//			studentCs++;
//		}
//		if (studentGrades[gradeCount] == 'D')
//		{
//			studentDs++;
//		}
//		if (studentGrades[gradeCount] == 'F')
//		{
//			studentFs++;
//		}
//	}

//	cout << studentAs << " students got A's" << endl;
//	cout << studentBs << " students got B's" << endl;
//	cout << studentCs << " students got C's" << endl;
//	cout << studentDs << " students got D's" << endl;
//	cout << studentFs << " students got F's" << endl;
//}

//10a
//9.4 Learn by Doing Exercises (broken into 3 files)

//int main()
//{
	//defining arrays
//	char firstName[15] = {};
//	char lastName[15] = {};
	//get firstName and lastName (call function getName)
//	getName(firstName, lastName);
	//format full name (call function formatName)
//	formatName(firstName, lastName);

//	return 0;
//}

//10b
//9.5 Learn by Doing Exercises (broken into 3 files)

int main()
{
	//defining arrays
	char firstString[30] = {};
	char secondString[30] = {};
	//greeting
	cout << "Welcome to the string first six character comparison program.\n";
	//get string inputs (call function getStrings)
	getStrings(firstString, secondString);
	//compare string inputs (call function compareStrings)
	compareStrings(firstString, secondString);
}