Menu Help
Nov 2, 2016 at 5:32am UTC
Everything used to work except my menu part, I am not sure what is wrong. I just want the menu to run once because I have to add more functions after this code. The menu should ask the user what day of the week it is and output it.
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
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {
string input = "" ;
cout << "Please enter your name (first and last):\n>" ;
getline(cin, input);
cout << "You entered: " << input << endl << endl;
cout << "Welcome " << input<< "!" << endl << endl;
{
int choice;
int menu(int choice);
bool Keeplooping = true ;
while (Keeplooping)
{
cout << "1- Monday\n" ;
cout << "2-Tuesday\n" ;
cout << "3-Wednesday\n" ;
cout << "4-Thursday\n" ;
cout << "5-Friday\n" ;
cout << "6-Saturday\n" ;
cout << "7-Sunday\n" ;
cout << " Please Enter the Number of the Day (1-7): " ;
cin >> choice;
menu(choice);
if (choice < 1 || choice >7)
{
Keeplooping = true ;
}
else
{
Keeplooping = false ;
}
switch (choice)
{
case 1:
cout << "So today is Monday!\n" ;
break ;
case 2:
cout << "So today is Tuesday!\n" ;
break ;
case 3:
cout << "So today is Wednesday!\n" ;
break ;
case 4:
cout << "So today is Thursday!\n" ;
break ;
case 5:
cout << "So today is Friday!\n" ;
break ;
case 6:
cout << "So today is Saturday!\n" ;
break ;
case 7:
cout << "So today is Sunday!\n" ;
break ;
default :
cout << "Looks like that isn't a good day! \n" ;
cout << "Choose again.\n" ;
cin >> choice;
}
return choice;
Nov 2, 2016 at 12:11pm UTC
The return choice;
will not only break the loop it also ends the program since it is in main.
Line 17 is only a prototype of the function. Not the function itself.
Nov 2, 2016 at 5:30pm UTC
Can you fix it? Idk what that means?
Topic archived. No new replies allowed.