aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab5/Functions.cpp
blob: 622941f6e1aa5c5051721b9a7cffeced40cc7111 (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
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  CODE FOR PROBLEM #1 (LEARN BY DOING) ON PAGE 253 IS BELOW  
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//#include "Header.h"
//
////puts scores into array
//void GetInput(float currStudent[], int NUM_SCORES)
//{
//	for (int i = 0; i < NUM_SCORES; i++)
//	{
//		cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": ";
//		cin >> currStudent[i];
//	}
//}
//
////translates scores to grades and puts into another array
//void ScoreToGrade(float currStudent[], char currStudGradeLTR[], int NUM_SCORES)
//{
//	for (int i = 0; i < NUM_SCORES; i++)
//	{
//		if (currStudent[i] < 65.0)
//		{
//			currStudGradeLTR[i] = 'F';
//		}
//		else if (currStudent[i] >= 65.0 && currStudent[i] < 75.0)
//		{
//			currStudGradeLTR[i] = 'D';
//		}
//		else if (currStudent[i] >= 75.0 && currStudent[i] < 84.0)
//		{
//			currStudGradeLTR[i] = 'C';
//		}
//		else if (currStudent[i] >= 84.0 && currStudent[i] < 92.0)
//		{
//			currStudGradeLTR[i] = 'B';
//		}
//		else if (currStudent[i] >= 92.0)
//		{
//			currStudGradeLTR[i] = 'A';
//		}
//	}
//}
//
////finds sum and average of scores
//void ScoreAvg(float currStudent[], int NUM_SCORES, float& scoreSum, float& scoreAvg)
//{
//	scoreSum = 0.0;
//	scoreAvg = 0.0;
//
//	for (int i = 0; i < NUM_SCORES; i++)
//	{
//		scoreSum += currStudent[i];
//	}
//
//	scoreAvg = scoreSum / NUM_SCORES;
//}
//
////counts frequency of different letter grades
//void Frequency(char currStudGradeLTR[], int NUM_SCORES, int& freqA, int& freqB, int& freqC, int& freqD, int& freqF)
//{
//	for (int i = 0; i < NUM_SCORES; i++)
//	{
//		if (currStudGradeLTR[i] == 'A')
//		{
//			freqA++;
//		}
//		if (currStudGradeLTR[i] == 'B')
//		{
//			freqB++;
//		}
//		if (currStudGradeLTR[i] == 'C')
//		{
//			freqC++;
//		}
//		if (currStudGradeLTR[i] == 'D')
//		{
//			freqD++;
//		}
//		if (currStudGradeLTR[i] == 'F')
//		{
//			freqF++;
//		}
//	}
//}
//
////displays list of scores with letter grades and class analysis
//void Display(float currStudent[], char currStudGradeLTR[], float scoreSum, float scoreAvg, int freqA, int freqB, int freqC, int freqD, int freqF, int NUM_SCORES)
//{
//	for (int i = 0; i < NUM_SCORES; i++)
//	{
//		cout << right << "\n\tScore #" << setw(2) << setfill(char(32)) << i + 1 << ":     "
//			<< setw(7) << setfill(char(32)) << left << currStudent[i] << "   " << currStudGradeLTR[i];
//	}
//
//	cout << "\n========================================================";
//	cout << "\n\n\tClass score average: " << scoreAvg;
//	cout << "\n\n\n\tFrequency of letter grades:";
//	cout << "\n\n\t\tA: " << freqA;
//	cout << "\n\t\tB: " << freqB;
//	cout << "\n\t\tC: " << freqC;
//	cout << "\n\t\tD: " << freqD;
//	cout << "\n\t\tF: " << freqF << "\n\n" << endl;
//}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  CODE FOR PROBLEM #2 (LEARN BY DOING) ON PAGE 260 IS BELOW  
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//#include "Header.h"
//
////prompts for first and last name and puts them into arrays
//void getInput(char firstName[], char lastName[])
//{
//	cout << "\n\n\tEnter first name: ";
//	cin.getline(firstName, 61);
//
//	cout << "\n\tEnter last name: ";
//	cin.getline(lastName, 61);
//}
//
////combines first and last names into another array, adds a comma and space between them
//void nameCombine(char firstName[], char lastName[], char fullName[])
//{
//	int index = 0;
//
//	for (int i = 0; lastName[i] != '\0'; i++) //puts lastName into fullName
//	{
//		fullName[i] = lastName[i];
//	}
//
//	for (int i = 0; fullName[i] != '\0'; i++) //counts fullName current length
//	{
//		index++;
//	}
//
//	fullName[index] = ',';     //adds comma and space
//	fullName[index + 1] = ' ';
//
//	for (int i = 0; firstName[i] != '\0'; i++)
//	{
//		fullName[i + index + 2] = firstName[i];
//	}
//}
//
////displays full name from array
//void display(char firstName[])
//{
//	cout << "\n\n====================================================";
//	cout << "\n\n\tYour full name is:    " << firstName << "\n" << endl;
//}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  CODE FOR PROBLEM #7 (EXERCISES) ON PAGE 273 IS BELOW  
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


//#include "Header.h"
//
////compares the first 6 characters of the two strings
//void compareStrings(char string_1[], char string_2[], int& flag)
//{
//	for (int i = 0; i <= 5; i++)
//	{
//		if (string_1[i] != string_2[i])
//		{
//			flag++;
//		}
//	}
//}