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
|
#include "Lab6_Header.h"
/* /// This is an Example that Martha Showed us in class
#define ARRAY_SIZE 5
void readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]);
int main()
{
int id_age[ARRAY_SIZE][2]{};
string name_gender[ARRAY_SIZE][2]{};
readData(id_age, name_gender);
}
void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
{
int again = 1, i = 0;
while (again && i < ARRAY_SIZE)
{
cout << "Enter the ID (0 to EXIT):";
cin >> again;
if (again)
{
intData[i][0] = again;
cout << "Enter the name: ";
getline(cin >> ws, stringData[i][0]);
cout << "Enter the age: ";
cin >> intData[i][1];
cout << "Enter the gender: ";
getline(cin >> ws,stringData[i][1];
cout << endl;
i++;
}
}
cout << endl;
}
*/
//10.10 Learn by Doing p282-283
void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
{
int again = 0, i = 0;
cout << "Another Club's Data? (1 for YES, 0 to exit) ";
cin >> again;
while (again && i < ARRAY_SIZE)
{
cout << "Enter the club name: ";
getline(cin >> ws, stringData[i][0]);
cout << "Enter number of members:";
cin >> intData[i][0];
cout << "Enter the Club president's name: ";
getline(cin >> ws, stringData[i][1]);
intData[i][1] = intData[i][0] * 75;
cout << endl;
cout << "Another Club's Data? (1 for YES, 0 to exit)";
cin >> again;
i++;
}
cout << endl;
}
void printData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
{
cout << setw(20) << "\t\t\tClub" << setw(10) << "\t\tmembers" << setw(20) << "\tPresident" << setw(10) << "\t\tDues $$\n\n";
for (int i = 0; i < ARRAY_SIZE; i++)
{
cout << "Record " << i + 1 << " is: \t";
for (int j = 0; j < 2; j++)
{
cout << setw(30) << stringData[i][j] << setw(10) << intData[i][j];
}
cout << endl;
}
}
//11c
//10.15 Programming Exercises
//pp 292 - 293
//10 pts #1
//
void isPalindrome(char User_Input[35])
{
char Rev[35]{};
strcpy(Rev, User_Input);
_strrev(Rev);
int Pal = strcmp(User_Input, Rev);
if (Pal == 0)
{
cout << "\n'" << User_Input << "' is a Palindrome! \n";
}
else if (Pal == 1)
{
cout << "\n'" << User_Input << "' is not a Palindrome.";
}
}
void isAlphaStr(char User_Input[35])
{
int i = 0;
int k = 0;
while (User_Input[i])
{
if (isalpha(User_Input[i]))
k++;
else k = 0;
i++;
}
//int k = 0;
//for (int i = 0; User_Input[i] == '\0'; i++)
//{
// if (isalpha(User_Input[i]))
// {
// k++;
// }
//}
if (k == 0)
{
cout << "\n'" << User_Input << "' does not contain just alphbetic characters\n";
}
else if (k != 0)
{
cout << "\n'" << User_Input << "' contains only alphabetic characters\n";
}
}
void countChar(char User_Input[35], char part_char)
{
int count = 0;
for (int i = 0; i < 35; i++)
{
if (User_Input[i] == part_char)
{
count++;
}
}
cout << "\ncharacter: " << part_char << " ... " << count << " counted.\n\n";
}
|