Just embed the switch statement to activate the menu choice within a do/while loop as indicated in the instruction
do
{
//display menu
switch(choice)
{
case 1:
//use for loop
break
case 2:
//use while loop
break
case 3:
//use do/while loop
break
case 6:
//exit
default
//output information to user
}//end switch
}while (choice != 6)
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
When you say something isn't working, it suggests that the code even compiles, which it doesn't. Does this work the way you expect?
#include <iostream>
using namespace std;
int main()
{
int option;
do
{
cout << " WYZ Company\n\n";
cout << " 1 - for loop\n\n";
cout << " 2 - while loop\n\n";
cout << " 3 - do while loop\n\n";
cout << " 4 - stuff01\n\n";
cout << " 5 - stuff02\n\n";
cout << " 6 - exit\n\n";
cout << "enter desired processing option here: [ ]\b\b";
cin >> option;
//display menu
switch(option)
{
case 1: cout << "you entered option 1\n";
break;
case 2: cout << "you entered option 2\n";
//use while loop
break;
case 3: cout << "you entered option 3\n";
//use do/while loop
break;
case 6: cout << "you entered option 6\n";
//exit
break;
default: cout << "wrong code dummy\n";
//output information to user
break;
} //end switch
}while (option != 6);
system("pause");
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
WolfPack
Postaholic
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115