#include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showmenu() { cout<<"Benevolent Order of Programmers Report " "a. display by name b. display by title " "c. display by bopname d. display by preference " "q. quit "; } struct bop { char fullname[strsize]; char title[strsize]; char bopname[strsize]; int preference; }; int main() { showmenu(); char ch; int i; bop newbop[BOPSIZE]= { {"Wimp Macho","Teahcer","WWW",0}, {"Raki Rhodes","Junior Programmer","RRR",1}, {"Celia Laiter","Star","MIPS",2}, {"Hoppy Hipman","Analyst Trainee","HHH",1}, {"Pat Hand","Doctor","LOOPY",2} }; cout<<"Enter your choice: "; while(cin>>ch && ch!='q') { switch(ch) { case 'a': for(i=0;i<BOPSIZE;i++) cout<<newbop[i].fullname<<endl; break; case 'b': for(i=0;i<BOPSIZE;i++) cout<<newbop[i].title<<endl; break; case 'c': for(i=0;i<BOPSIZE;i++) cout<<newbop[i].bopname<<endl; break; case 'd': for(i=0;i<BOPSIZE;i++) { if(0==newbop[i].preference) cout<<newbop[i].fullname<<endl; else if(1==newbop[i].preference) cout<<newbop[i].title<<endl; else if(2==newbop[i].preference) cout<<newbop[i].bopname<<endl; } break; //case 'q':cout<<"Bye! "; } cout<<"Next choice: "; } cout<<"Bye! "; system("pause"); return 0; }