### Trying to loop craps game multiple times to find house advantage

The craps game below is correct...I just wanted to know what I would need to do to loop the game, say, 1000 times. I want to see what the house advantage would be when this game is run many times.

Thanks!

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566`` ``````#include #include #include using namespace std; int rollDice(); int main() { enum Status {CONTINUE, WON, LOST}; int myPoint = 0; Status gameStatus; srand(time(0)); int sumOfDice = rollDice(); switch(sumOfDice){ case 7: case 11: gameStatus = WON; break; case 3: case 4: case 12: gameStatus = LOST; break; default: gameStatus = CONTINUE; myPoint = sumOfDice; cout << "Point is: " << myPoint << endl; break; } while(gameStatus == CONTINUE){ sumOfDice = rollDice(); if (sumOfDice == myPoint) gameStatus = WON; if (sumOfDice == 7) gameStatus = LOST; } if (gameStatus == WON) cout << "Player wins!" << endl; else cout << "Player loses!" << endl; } int rollDice(){ int dice1 = 1 + rand()%6; int dice2 = 1 + rand()%6; int total = dice1 + dice2; cout << "Player rolled " << dice1 << " and " << dice2 << " for a total of " << total << endl; return total; }``````
Last edited on
Topic archived. No new replies allowed.