okay i need some help with my program i keep geting errors everytime i fix something...i have many questions.. please dont just tell me what to fix, please explain it as well. but be aware im extreamely new to C++ so explain them ina way a newbie would understand =)
after i open it it shows intro screen then asks the player there name, i type in a name, and then instead of switching over and going on through the game.... the intro screen pops right back up asking there name again....
please help?!?
=(
here's my code... (I UPDATED IT)
Code:#include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int Diceroll(); int Introscreen(); void Tryagain(); void Win(); int Totalbears; int Dicenumber; int Useranswer; int Totalcorrect; string PLAYAGAIN; string NAME; bool PLAY = true; int main() { srand((unsigned)time(NULL)); string PLAYAGAIN = "yes"; while (PLAYAGAIN == "yes") Introscreen(); while(PLAY) { Totalcorrect = 0; for (int iCOUNT=1; iCOUNT<11; iCOUNT++) { if (Useranswer==3) { Win(); } Diceroll(); cout<<"How many polar bears do you see around the ice holes?"<<endl; cin>>Useranswer; if (Useranswer == Totalbears) { cout<<"Correct! =D"<<endl; Totalcorrect++; } else { cout<<"Incorrect! The right answer was: "<<Totalbears<<endl; } system("pause"); Tryagain(); } } return 0; } void LOSE (string NAME) { //the losing screen cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl; cout<<"! !"<<endl; cout<<"! Sorry, !"<<endl; cout<<"! You Lose! !"<<endl; cout<<"! !"<<endl; cout<<"! !"<<endl; cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl; cout<<endl; cout<<"SORRY "<<NAME<< " YOU LOST"<<endl<<endl; cout<<"BETTER LUCK NEXT TIME"<<endl; } //the intoduction screen int Introscreen() { cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl; cout<<"! !"<<endl; cout<<"! !"<<endl; cout<<"! Ice and Dice !"<<endl; cout<<"! !"<<endl; cout<<"! !"<<endl; cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl; cout<<endl; cout<<"Game details:"<<endl; cout<<"The name is in the game, and the game is in the name."<<endl; cout<<"and the name of the game is Polar Bears Around An Ice Hole."<<endl; cout<<"Some people call this Petals Around A Rose."<<endl<<endl; cout<<endl; cout<<"Wish to play? Please enter your name here:"<<endl; cin>>NAME; return 0; } int Diceroll() { Totalbears = 0; for (int numRoll = 1; numRoll<4; numRoll++) { Dicenumber=1+rand()%6; switch(Dicenumber) { case 1: { cout<<"*******"<<endl; cout<<"* *"<<endl; cout<<"* 0 *"<<endl; cout<<"* *"<<endl; cout<<"*******"<<endl; Totalbears = Totalbears+0; break; } case 2: { cout<<"********"<<endl; cout<<"* 0 *"<<endl; cout<<"* *"<<endl; cout<<"* 0 *"<<endl; cout<<"********"<<endl; Totalbears = Totalbears+0; break; } case 3: { cout<<"*******"<<endl; cout<<"* 0 *"<<endl; cout<<"* 0 *"<<endl; cout<<"* O *"<<endl; cout<<"*******"<<endl; Totalbears = Totalbears+2; break; } case 4: { cout<<"*********"<<endl; cout<<"* 0 0 *"<<endl; cout<<"* *"<<endl; cout<<"* 0 0 *"<<endl; cout<<"*********"<<endl; Totalbears = Totalbears+0; break; } case 5: { cout<<"*********"<<endl; cout<<"* O O *"<<endl; cout<<"* O *"<<endl; cout<<"* O O *"<<endl; cout<<"*********"<<endl; Totalbears = Totalbears+4; break; } case 6: { cout<<"********"<<endl; cout<<"* O O *"<<endl; cout<<"* O O *"<<endl; cout<<"* O O *"<<endl; cout<<"********"<<endl; Totalbears = Totalbears+0; break; } default: break; }//end of switch } return 0; } void Win () { cout<<"Congratulations, "<<NAME<<", You have won! =D"<<endl; } void Tryagain() { cout<<"Want to play again? (yes or no)"<<endl; cin>>PLAYAGAIN; if (PLAYAGAIN == "no") { PLAY = false; cout<<"Bye"<<endl; } if (PLAYAGAIN == "yes") { PLAY = true; cout<<"Okay!"<<endl; } }