-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_4.cpp
74 lines (63 loc) · 1.54 KB
/
6_4.cpp
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
#include <iostream>
const int strsize = 20;
struct bop {
char fullname[strsize];
char title[strsize];
char bopname[strsize];
int preference;
};
int main()
{
using namespace std;
bop member[5] = {
{"Wimp Macho","English Teacher","DEMON", 0},
{"Raki Rhodes", "Junior Programmer", "BOOM", 1},
{"Celia Laiter", "Super Star", "MIPS", 2},
{"Hoppy Hipman", "Analyst Trainee", "WATEE", 1},
{"Pat Hand", "Police", "LOOPY", 2}
};
char ch;
cout << "Benevolent Order of Programmers Report" << endl
<< "a. display by name\tb. display by title" << endl
<< "c. display by bopname\td. display by preference" << endl
<< "q. quit" << endl;
cout << "Enter your choice: ";
while(cin >> ch && 'q' != ch)
{
if('a' != ch && 'b' != ch && 'c' != ch && 'd' != ch)
{
cout << "Please enter a a, b, c, d";
continue;
}
switch(ch)
{
case 'a':
for(int i = 0; i < 5; i++)
cout << member[i].fullname << endl;
break;
case 'b':
for(int i = 0; i < 5; i++)
cout << member[i].title << endl;
break;
case 'c':
for(int i = 0; i < 5; i++)
cout << member[i].bopname << endl;
break;
case 'd':
for(int i = 0; i < 5; i++)
{
if(0 == member[i].preference)
cout << member[i].fullname << endl;
else if(1 == member[i].preference)
cout << member[i].title << endl;
else
cout << member[i].bopname << endl;
}
break;
}
cout << "Next choice: ";
}
cout << "Bye!" << endl;
// system("pause");
return 0;
}