I've been learning C++ for the past 2 weeks and this is my assignment:
Craps is a simple dice game often played in casinos. A player throws a pair of dice (often repeatedly), with the following win/loss conditions:
A 7 or 11 on the first roll wins.
A 2, 3, or 12 on the first roll loses.
Under all other circumstances, rolling will continue.
The total on the first roll is called the point. Rolling will continue until either:
The point is rolled (win)
A 7 is rolled (lose)
KEEP IN MIND: My C++ is VERY basic, i've only learned the basics of boolean and while + if/else. Please try to keep the help basic if possible as I don't want to be too confused.
This is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <iostream>
using namespace std;
// Beginning User Commands
int main ()
{
int dice1;
int dice2;
int point;
char R;
char response;
dice1 = 1 + rand() % 6;
dice2 = 1 + rand() % 6;
point = dice1 + dice2;
cout << "Let's Play Craps!" << endl;
cout << "Enter R to roll : ";
cin >> R;
cout << "Your Roll is "<< dice1 <<" and " << dice2 << " which gives a total roll of " << point << "." << endl;
if (point == 7 || point == 11)
{
cout<< "You Win!!"<< endl;
}
else if (point == 2 || point ==3 || point == 12)
{
cout << "You Lose!!"<< endl;
cout << "Would you like to play again? (Y/N)";
cin >> response;
while (response =='y' || response=='Y');
}
else
{
cout << "You did not Win or Lose! Do you want to roll again? (Y/N)";
cin >> response;
while (response =='y' || response=='Y');
}
cout << endl;
}
|
What I am trying to figure out is how to make the program repeat. Right now, I can get the 2 random numbers to generate (It always comes out to 6 and 6, but the professor said that's okay) and then I can ask the user if he wants to play again.
They can press Y but nothing happens, how can I repeat the program?
I just learned 'char' on my own today and tried to implement it into my program, so please tell me if I did something wrong.
Thank you!