This is my code:
Code:
#include "backtobasics.h"
#include "baic2.h"
using namespace std;
int menu()
{
int choice;
cout << " **** Menu ****" << endl << endl; //States the options on the menu
cout << "(1) Play Game." << endl;
cout << "(2) Options." << endl;
cout << "(3) Multiplayer." << endl;
cout << "(4) Quit." << endl << endl;
cout << ": ";
cin >> choice; //enter there choice, 1,2,3 or 4
return choice;
return 0;
}
int main()
{
int choice = menu(), i, second;
string firstName, lastName;
cout << "You chose option " << choice << endl; //tells the user their choice
cout << "Is this correct? If yes click 1, if no click 2. (2 mistakes Remaining)" << endl; //asks them if it is correct (1) or not (2)
cout << " (1)"<<endl;
cout << " (2)"<<endl;
cin>>second; //they enter their choice 1 or 2
if (second==1){ // if they enter 1, it says that they can continue
cout<< "Click to continue."<<endl;
cin.get();
return 0;
}
else if (second==2) // if they enter 2, it gives them the menu again
{
cout << " **** Menu ****" << endl << endl; //States the options on the menu
cout << "(1) Play Game." << endl;
cout << "(2) Options." << endl;
cout << "(3) Multiplayer." << endl;
cout << "(4) Quit." << endl << endl;
cout << ": ";
cin >> choice; //enter there choice, 1,2,3 or 4
int menu(), i, second;
cout << "You chose option " << choice << endl; //tells the user their choice
cout << "Is this correct? If yes click 1, if no click 2. (1 mistake Remaining)" << endl; //asks them if it is correct (1) or not (2)
cout << " (1)"<<endl;
cout << " (2)"<<endl;
cin>>second; //they enter their choice 1 or 2
if (second==1){ // if they enter 1, it says that they can continue
cout<< "Click to continue."<<endl;
cin>>i
;
return 1;
}
else if (second==2) // if they enter 2, it gives them the menu again
{
while (second==2)
second++;
cout << " **** Menu ****" << endl << endl; //States the options on the menu
cout << "(1) Play Game." << endl;
cout << "(2) Options." << endl;
cout << "(3) Multiplayer." << endl;
cout << "(4) Quit." << endl << endl;
cout << ": ";
cin >> choice; //enter there choice, 1,2,3 or 4
return choice;
}
}
else (second>2); // if they enter a number bigger than 2, it tells them that it is invalid
{
cout<<"You have not entered a valid choice."<<endl;
cin>>i;
return 1;
}
{
cout<<"Welcome, what is your name? First and Last. "<<endl;
cin>>firstName>>lastName;
cout<<endl<<"Hello " << firstName << lastName;
cin.get ();
return 0;
}
return 0;
}
The bottom part does not play. Does anyone know why?
Code:
{
cout<<"Welcome, what is your name? First and Last. "<<endl;
cin>>firstName>>lastName;
cout<<endl<<"Hello " << firstName << lastName;
cin.get ();
return 0;
}