Help with program (Menu and choices)

Im currently working on a basic game for school, this is my first year doing computer science and this is one of my projects.

Currently the program runs well however in the program when I want the player to select either choice 1 or 2 it always runs choice 1 first and then choice 2 even though I separated them...

I would also like to ask how can I make the choice 0 in my menus also known as "Exit" actually exit and go to the last menu it was on?

Any suggestions?


Here is the code, I think the error might be at around line 51 or when I separated the choices at line 146.







/*Main Menu*/
do
{system("cls");
cout<<"Welcome to the factory, choose one of the four numbers, go to the store to buy "<< endl;

cout<<"parts,check your tanks or start the day!"<<endl;
cout<<" "<<endl;
cout << "1. Go to the store." << endl;
cout<<" "<<endl;
cout << "2. Go to the tanks" << endl;
cout<<" "<<endl;
cout << "9. Start the day." << endl;
cout<<" "<<endl;
cout << "0. Quit the game." << endl;
cin >> mmChoice;







if(mmChoice == 1); /*choice 1*/
{
do
{
cout << "1. Buy Iron. Price 3000 Cash" << endl;
cout <<" "<<endl;
cout << "2. Buy Steel. Price 5000 Cash" << endl;
cout <<" "<<endl;
cout << "3. Buy Glass. Price 1000 Cash" << endl;
cout <<" "<<endl;
cout << "4. Check parts" << endl;
cout <<" "<<endl;
cout << "0. Exit the store" << endl;
cout <<" "<<endl;
cout <<"You currently have " << Papercash << endl;
cin >> storeChoice;



if (storeChoice==1 ) /*choice 1 in store*/
{
cout << "You bought iron" << endl;
Papercash= Papercash - 3000;
Iron=Iron + 1;
cout<<"You now have "<<Iron<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");

}

else if (storeChoice==2) /*choice 2 in store*/
{

cout << "You bought steel" << endl;
Papercash= Papercash - 5000;
Steel=Steel + 1;
cout<<"You now have "<<Steel<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");
}

else if (storeChoice==3) /*choice 3 in store*/
{
cout<<"You bought glass"<< endl;
Papercash= Papercash - 1000;
Glass=Glass+1;
cout<<"You now have "<<Glass<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");
}
else if (storeChoice==4)
{cout<<"You have "<<Iron<<" and "<<Steel<<" and "<<Glass<<endl;
system("cls");
cout<<"You have "<<Iron<<" and "<<Steel<<" and "<<Glass<<endl;}

else if (storeChoice==0) /*quit store*/
{
storeChoice=0;
}








}while(storeChoice != 0); /*COSTS IRON 3000 STEEL 5000 GlASS 1000*/


}

if(mmChoice == 2);
{
do
{
{cout<<"Here are all of the tanks you have so far.You can choose build more tanks before starting the day." << endl;
cout<<"1.Renault FT Cost:1000 Cash,1 Iron, 1 Steel, 1 Glass. Sells for 15000 Cash." << endl;
cout<<"2.Panzer IV Cost:2000 Cash, 2 Iron, 1 Steel, 1 Glass. Sells for 16000 Cash."<<endl;
cout<<"3.T-34 Cost:2000 Cash,2 Iron,2 Steel, 1 Glass. Sells for 21000 Cash."<<endl;
cout<<"4.Churchill 1 Cost:3000 Cash 3 Iron, 2 Steel, 2 Glass. Sells for 27000 Cash."<<endl;
cout<<"5.Tiger 1 Cost:10000 5 Iron, 5 Steel, 2 Glass. Sells for 70000 Cash."<<endl;
cin >> Tankchoice ;
}




/*Bought tanks text*/


if (Tankchoice==1 ) /*choice 1 in Tanks*/
{
cout << "You bought a Renault FT" << endl;
Papercash= Papercash - 1000;
Iron=Iron - 1;
Steel=Steel - 1;
Glass=Glass - 1;
RenaultFT=RenaultFT + 1;
cout<<"You have "<<Iron<<" and "<<Steel<<" and "<<Glass<<" left"<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");}

if (Tankchoice==2 ) /*choice 2 in Tanks*/
{
cout << "You bought a Panzer IV" << endl;
Papercash= Papercash - 2000;
Iron=Iron - 2;
Steel=Steel - 1;
Glass=Glass - 1;
Panzer4=Panzer4 + 1;
cout<<"You have "<<Iron<<" and "<<Steel<<" and "<<Glass<<" left"<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");}

if (Tankchoice==3 ) /*choice 3 in Tanks*/
{
cout << "You bought a T-34" << endl;
Papercash= Papercash - 2000;
Iron=Iron - 2;
Steel=Steel - 2;
Glass=Glass - 1;
T34=T34 + 1;
cout<<"You have "<<Iron<<" and "<<Steel<<" and "<<Glass<<" left."<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");}

if (Tankchoice==4 ) /*choice 4 in Tanks*/
{
cout << "You bought a T-34" << endl;
Papercash= Papercash - 2000;
Iron=Iron - 2;
Steel=Steel - 2;
Glass=Glass - 1;
T34=T34 + 1;
cout<<"You have "<<Iron<<" and "<<Steel<<" and "<<Glass<<" left."<<endl;
cout <<"You have "<< Papercash <<" left"<< endl;
system("pause");
system("cls");}



}
while (Tankchoice !=0);

}
while (mmChoice != 0);



}
while(mmChoice!=0);

return 0;
} /* <- belongs to first do*/

Last edited on
Topic archived. No new replies allowed.