The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 327 Weeks Ago, 4 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
Week 6: Create a hierarchy chart showing the logical components of your program. Modularize your code according to your chart using the practices learned this week. Your menu should now call individual modules to do the work of the program. #include <iostream> using namespace std; int main()
{
char ch='Y';
int gateNo; // integer for gate number
int choice;
char movies[3][100] = {"Movie: Beauty and the beast", "Movie: The Circle", "Movie: Boss Baby"};
int gateNos[3] = {1, 2, 3};
char timing[3][100] = {"Time: 1:00pm", "Time: 3:00pm", "Time: 5:00pm"}; cout << "Menu" << endl;
cout << "1. Check movies, their time and gate\n2. Exit\n";
//validate user input in a loop
while(true) {
cin >> choice;
if(choice < 1 || choice > 2) {
cout << "Menu" << endl;
cout << "1. Check movies, their time and gate\n2. Exit\n"; } else {
break;
}
}
if(choice == 1) {
cout << "Movies with their time and gate..." << endl; while( ch=='y' || ch=='Y'){ //user prompt for gate number
for(int i = 0; i < 3; i++) {
cout << (i+1) << ". " << movies[i] << endl;
}
while(true) {
bool valid = false;
cout << endl <<"Please enter the Gate number : ";
cin >> gateNo;
for(int i = 0; i < 3; i++) {
if(gateNos[i] == gateNo) {
valid = true;
break;
}
}
if(!valid) {
cout << "Invalid gate no!!" << endl; continue;
}
break;
} // details of movies...
cout << endl << movies[gateNo-1] << endl;
cout << timing[gateNo-1] << endl;
cout << "Gate: " << gateNo << endl;
// user prompt to continue
cout << endl << "To cont... press[Y/N]: ";
cin >> ch;
}
} cout << "Thanks for using Movies menu program!" << endl;
system("pause");
return 0;
}
-----------