-
Notifications
You must be signed in to change notification settings - Fork 1
/
ex04.cpp
66 lines (58 loc) · 1.85 KB
/
ex04.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
#include <iostream>
const int strsize = 20;
const int ArSize = 5;
struct bop {
char fullname[strsize];
char title[strsize];
char bopname[strsize];
int preference;
};
int main()
{
using namespace std;
bop arrbop[ArSize]{
{"Wimp Macho", "Engineer", "MACHO", 1},
{"Raki Rhodes", "Junior Programmer", "RAKI", 2},
{"Celia Laiter", "Director", "MIPS", 0},
{"Hoppy Hipman", "Analyst Trainee", "HIPMAN", 1},
{"Pat Hand", "Manager", "LOOPY", 2}
};
cout << "Benevolent Order of Programmers Report\n"
" a. display by name\t b. display by title\n"
" c. display by bopname\t d. display by preference\n"
" q. quit\n";
cout << "Enter your choice: ";
char ch;
cin >> ch;
while(ch !='q')
{
switch (ch)
{
case 'a': {
for(int i = 0; i < ArSize; i++)
cout << arrbop[i].fullname << endl;
break; }
case 'b': {
for(int i = 0; i < ArSize; i++)
cout << arrbop[i].title << endl;
break; }
case 'c': {
for(int i = 0; i < ArSize; i++)
cout << arrbop[i].bopname << endl;
break; }
case 'd': {
for(int i = 0; i < ArSize; i++)
switch (arrbop[i].preference)
{
case 0: cout << arrbop[i].fullname << endl; break;
case 1: cout << arrbop[i].title << endl; break;
case 2: cout << arrbop[i].bopname << endl; break;
}
break; }
}
cout << "Next choice: ";
cin >> ch;
}
cout << "Bye!" << endl;
return 0;
}