int DICEROLL();
int INTROSCREEN();
void RETRY();
void WIN();
int BEARTOTAL;
int DICENUMBER;
int USERANSWER;
int TOTALCORRECT;
string NAME;
bool PLAY = true;
void main ()
{
//RANDOMLY GENERATES NUMBERS
srand((unsigned)time(NULL));
//SCREEN SHOWN WHEN PROGRAM STARTS
INTROSCREEN ();
while(PLAY)
{
string PLAYAGAIN;
TOTALCORRECT = 0;
//LOOP
for (int iCOUNT=1; iCOUNT<11; iCOUNT++)
{
//CHECKS IF USER HAS ENOUGH CORRECT ANSWERS
if (USERANSWER==3)
{
//SCREEN SHOWN WHEN PLAYER WINS
WIN();
}
//ROLLS AND DISPLAYS DICE
DICEROLL();
//ASKS USER A QUESTION
cout<<"HOW MANY POLAR BEARS ARE AROUND THE ICE HOLES?"<<endl;
cin>>USERANSWER;
//CHECKS THE USERS ANSWER
if (USERANSWER == BEARTOTAL)
{
cout<<"THATS CORRECT!"<<endl;
TOTALCORRECT++;
}
else
{
cout<<"SORRY, THAT IS INCORRECT. THE CORRECT ANSWER IS: "<<BEARTOTAL<<endl;
}
system("pause");
RETRY();
}//LOOP END
}//WHILE END
}//MAIN END
void LOSE (string NAME)//LOSING SCREEN
{
//SCREEN SHOWN WHEN THE PLAYER LOSES
cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl;
cout<<"! !"<<endl;
cout<<"! !"<<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;
}
//INTRO SCREEN
int INTROSCREEN ()
{
//SCREEN SHOWN WHEN PROGRAM STARTS
cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<< endl;
cout<<"! !"<<endl;
cout<<"! !"<<endl;
cout<<"! ICE AND DICE !"<<endl;
cout<<"! !"<<endl;
cout<<"! !"<<endl;
cout<<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl;
cout<<endl;
//HINTS ABOUT THE RULES OF THE GAME
cout<<"HERE ARE AOME DETAILS ABOUT THE GAME."<<endl;
cout<<"LETS SEE IF YOU CAN FIGURE OUT THE RULES WITH THESE HINTS: "<<endl<<endl;
cout<<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 ALSO CALL THIS PETALS AROUND A ROSE"<<endl<<endl;
cout<<endl;
cout<<"ENTER YOUR NAME PLEASE"<<endl;
cin>>NAME;
}
int DICEROLL()
{
//SETS DICE TO 0 FOR EVERY ROLL
BEARTOTAL = 0;
//ROLLS DICE 3 TIMES
for (int numRoll = 1; numRoll<4; numRoll++)
{
//GENERATES A RANDOM NUMBER BETWEEN 1-6
DICENUMBER=1+rand()%6;
case 4:
{
//SHOW DICE & TOTAL BEARS
cout<<"*******"<<endl;
cout<<"* O O *"<<endl;
cout<<"* O *"<<endl;
cout<<"* O O *"<<endl;
cout<<"*******"<<endl;
BEARTOTAL = BEARTOTAL+4;
break;
}
case 5:
{
//SHOW DICE & TOTAL BEARS
cout<<"*******"<<endl;
cout<<"* O O *"<<endl;
cout<<"* O O *"<<endl;
cout<<"* O O *"<<endl;
cout<<"*******"<<endl;
BEARTOTAL = BEARTOTAL+0;
break;
}
default:
{
break;
}
}//SWITCH END
}//FOR END
return 0;
}//INT END
void WIN ()
{
cout<<"CONGRATULATIONS "<<NAME<<" YOU WON"<<endl;
}
void RETRY()
{
cout<<"WOULD YOU LIKE TO PLAY AGAIN?"<<endl;
cin>>PLAYAGAIN;
if (PLAYAGAIN == "no")
{
PLAY = false;
cout<<"GOODBYE"<<endl;
}