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);
}
}