Menu Problems

So this is my first time, and I need someone to please solve the problem for me. This is my program. When I ask it to enter on the home menu, it takes me back to the second menu and asks me again if I would like to exit. Could someone help me. Get rid of this problem.
Sorry no tags.

#include <iostream>
using namespace std;
int main()
{

int choice;
bool gameOn = true;
while (gameOn != false)
{
cout << "\n\t\tWelcome To Zoheb.I.Currimbhoy's Age Calculator\n";
cout << " \n\n1 - Start the Questionaire.\n";
cout << " \n2 - Exit.\n";
cout << " \nEnter your choice and press return: ";
cin >> choice;

switch (choice)
{
case 1:
cout << "\n\n\t\t\t\tStart The Questionaire\n";
int birthmonth,birthyear;
int currentmonth,currentyear;
int agey,agem;
cout<<"\n\n\t\tUsing C++, Find Your Age By Answering The Questions\n\n";
cout<<"\n\nEnter Your Birth Year(Eg:1989):";
cin>>birthyear;
cout<<"\n\nEnter Your Birth Month(Eg:7):";
cin>>birthmonth;
cout<<"\n\nEnter The Current Month(Eg:7):";
cin>>currentmonth;
cout<<"\n\nEnter The Current Year(Eg:2010):";
cin>>currentyear;
agey=currentyear-birthyear;
agem=currentmonth-birthmonth;
cout<<"\n\n\t\t\tYour Age is "<<agey<<" Years And "<<agem<<" Months ";
printf("\n\n\n\t Thanks for using the age calculator. Have a great day.\n");
break;
case 2:
cout << "End of Program.\n";
gameOn = false;
break;
default:
cout << "Not a Valid Choice. \n";
cout << "Choose again.\n";
cin >> choice;
while (gameOn!=false);

bool gameOn = true;
while (gameOn != false)
{
cout << " \n\n1- Re-Start the Questionaire.\n";
cout << " \n\n2- Exit.\n";
cout << " \nEnter your choice and press return: ";
cin >> choice;
switch (choice)
{
case 1:
cout << "\n\n\t\t\t\tStart The Questionaire\n";
int birthmonth,birthyear;
int currentmonth,currentyear;
int agey,agem;
cout<<"\n\n\t\tUsing C++, Find Your Age By Answering The Questions\n\n";
cout<<"\n\nEnter Your Birth Year(Eg:1989):";
cin>>birthyear;
cout<<"\n\nEnter Your Birth Month(Eg:7):";
cin>>birthmonth;
cout<<"\n\nEnter The Current Month(Eg:7):";
cin>>currentmonth;
cout<<"\n\nEnter The Current Year(Eg:2010):";
cin>>currentyear;
agey=currentyear-birthyear;
agem=currentmonth-birthmonth;
cout<<"\n\n\t\t\tYour Age is "<<agey<<" Years And "<<agem<<" Months ";
printf("\n\n\n\t Thanks for using the age calculator. Have a great day.\n");
break;
case 2:
cout << "End of Program.\n";
gameOn = false;
break;
default:
cout << "Not a Valid Choice. \n";
cout << "Choose again.\n";
cin >> choice;
break;
while(gameOn!=false);
return 0;
}
while (gameOn!=false);
}
}
return (0);
}
}

Last edited on
dude! is this what you want to your output?

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
#include < iostream >

using namespace std;

void main ( )
{
	int birthmonth, birthyear;
	int currentmonth, currentyear;
	int agey, agem;
	char choice;

	cout << "\n\t\tWelcome To Zoheb.I.Currimbhoy's Age Calculator\n\n\n";

	do
	{
		cout << "[1] Start the Questionaire." << endl;
		cout << "[2] Exit." << endl;

		cout << " \nEnter your choice and press return: ";
		cin >> choice;

		switch ( choice )
		{
			case '1':
			{
				cout << "\n\n\t\t\t\tStart The Questionaire\n";
				cout << "\n\n\t\tUsing C++, Find Your Age By Answering The Questions\n\n";
				cout << "\n\nEnter Your Birth Year(Eg:1989):";
				cin >> birthyear;
				cout << "\n\nEnter Your Birth Month(Eg:7):";
				cin >> birthmonth;
				cout << "\n\nEnter The Current Month(Eg:7):";
				cin >> currentmonth;
				cout << "\n\nEnter The Current Year(Eg:2010):";
				cin >> currentyear;
				agey = currentyear - birthyear;
				agem = currentmonth - birthmonth;
				cout << "\n\n\t\t\tYour Age is " <<  agey << "Years And " << agem << " Months ";
				cout << "\n\n";
				break;
			}

			case '2':
			{
				cout << "\n\n\n\tThanks for using the age calculator. Have a great day.\n\n\n";
				break;
			}
		}
	}
	while ( choice != '2' );

}
Last edited on
Topic archived. No new replies allowed.