Please help me with a Do While loop.
I have to promp the user to select a loop structure using a Do While loop.
User may choose from While "W", Do While "D", or For "F".
Code must restrict the user to enter a valid selection. If the user's selection is invalid, the function clears the screen and re_displays a menu. This will be repeated until the user enters a valid selection.
This is what I have so far and it doesnt run at all. Please help.
Code:#include<iostream> #include<stdlib.h> using namespace std; void main() { void DisplayBanner(); int PromptUserForSelection(); DisplayBanner(); PromptUserForSelection(); } void DisplayBanner() { system("cls"); cout<<" PROGRAM: Labs456\n\n"; cout<<" AUTHOR: JT\n"; cout<<" DATE: Saturday July 7, 2007\n"; cout<<" COMPILER: Visual C++ using VS2005\n"; cout<<" COMPUTER: HP PC\n"; cout<<" VERSION: VX.0\n"; cout<<" PURPOSE: Promting the user to enter a selection.\n"; cout<<"\n\n\t\t Press <Enter> to Continue"; cin.get(); } int PromptUserForSelection() { char selection, 'W', 'D', 'F'; do { cout << "\n\n"; cout << "Structure Selection\n\n"; cout << "While W" << endl; cout << "Do While D" << endl; cout << "For F\n\n" << endl; cout << "Enter Selection <Q to Quit>: "; cin >> selection; cout << endl; } while (selection != W || D || F); if (selection = W) cout << "You have chosen While" << endl; if (selection = D) cout << "You have chosen Do While" << endl; if (selection = F) cout << "You have chosen For" << endl; return 0; }



LinkBack URL
About LinkBacks


