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
|
#include <iostream>
int main()
{
using namespace std;
const int noArray = 3;
const int strsize = 25;
struct bop {
char fullname[strsize];
char title[strsize];
char bopname[strsize];
int preference;
};
bop bopArray[noArray] =
{
{ "Tank Johnson", "Junior Programmer", "Wimp Macho", 1},
{ "Skull Murphy", "Analyst Trainee", "Guitar Master", 2},
{ "Giri Guru", "Trader", "GG", 2}
};
cout << "Benevolent Order of Programmers" << endl;
cout << "a. display by name b. display by title" << endl;
cout << "c. display by BOP-Name d. display by preference" << endl;
cout << "q. quit" << endl;
char choice;
while (cin >> choice)
{
if (choice != 'a' && choice != 'b' && choice != 'c' && choice != 'd' && choice != 'q')
{
cin.clear();
while (cin.get() != '\n')
continue;
cout << "Please enter a), b), c), d), or q)" << endl;
}
switch (choice)
{
case 'a': cout << "Display by Name" << endl;
for (int i = 0; i <= (noArray - 1); i++)
cout << bopArray[i].fullname << endl;
break;
case 'b': cout << "Display by Title" << endl;
for (int i = 0; i <= (noArray - 1); i++)
cout << bopArray[i].title << endl;
break;
case 'c': cout << "Display by BOP-Name" << endl;
for (int i = 0; i <= (noArray - 1); i++)
cout << bopArray[i].bopname << endl;
break;
case 'd': cout << "Display by Preference" << endl;
for (int i = 0; i <= (noArray - 1); i++)
{
cout << bopArray[i].fullname << endl;
switch (bopArray[i].preference) // Code seems to be skipping this part
{
case '1': cout << bopArray[i].title << endl;
continue;
case '2': cout << bopArray[i].bopname << endl;
continue;
}
}
}
}
cin.get();
return 0;
}
|