### Problem with Craps Program

Hey guys been trying to figure out what I'm doing wrong for like an hour. For some reason

For some reason it won't read in Loss at all it will only say that all the games played are all wins.

Any help, advice, or tips are appreciated :)

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207`` ``````#include #include #include #include #include #include #include #include #include #include using namespace std; //Funcation Prototype int roll(); //Rolls one die int roll2(); //Rolls two die and adds them together int readIntPos(string); //Reads in a response from prompt void setRand(int); //Sets seed to srand or time depending on user input bool playCraps(int); //Plays one game of craps int printGameStats(int,int); //Prints game stats //Main int main () { int win = 0; //number of wins int loss = 0; //number of losses int seed; //seed bool gameResult; //gameResult is the result of the game of craps played int numGames = 0; //number of games to be played //Prompt user for number of games to be played numGames = readIntPos("Enter the number of games: "); //Call playCraps gameResult=playCraps(seed); for (int x=0; x> value; while ( value <=0 ) { cout << "Invalid imput - Must be a positive"; cout << endl; cout << prompt; cin >> value; } return value; } //------------------------------------- //Name: setRand //Purpose: if seed = 999 then srand time //Parameters: seed //Returns: //------------------------------------- void setRand(int value) { if(value == 999) { srand((time(NULL))); } else { srand(value); } } //------------------------------------- //Name: playCraps //Purpose: play a full game of craps //Parameters: //Returns: interger between 1 and 6 //------------------------------------- bool playCraps(int seed) { //Variable Declaration int die = 0; int totalRoll = 0; string prompt = ""; int numGames = 0; int gameNum = 0; int pointNum = 0; int value = 0; bool result; //Promp user for seed seed = readIntPos("Enter seed for random number generator (999 to use time): "); setRand(seed); pointNum = roll2(); if (pointNum == 7 || pointNum == 11) { result = true; } else if (pointNum == 2 || pointNum == 3 || pointNum == 12 ) { result = false; } else { die = roll2(); while(die != pointNum and die != 7) { die = roll2(); } if(die == pointNum) { result = true; } else if(die == 7) { result = false; } } return result; } //------------------------------------- //Name: printGameStats //Purpose: print game stats //Parameters: int wins int losses //Returns: game stats //------------------------------------- //printGameStats(int loss, int win) //{ // percent = ((win/loss)* (100)) // // // // // //} ``````
Topic archived. No new replies allowed.