Hi there,

I am designing this simple game to generate two random numbers using RNG and get their sum, if it is 7 or 11 the player wins and the budget of the game is incremented by the bet the player has input at the beginning of the game, if the sum is 2 or 3 or 12 the player loses and the budget is decremented by the bet the player has made, if the sum is otherwise other 2 random numbers are generated and their sum is got using the same bet the user has made at the beginning without re-asking the user for the bet..

Now, the game is working but the problem is that when the sum is otherwise and it repeats the RNG process it keeps getting the same results for so many times and the 2 randomly generated numbers change after a long time.. what is wrong with that?

All thanks,

-Amy

Code:// Including librarie(s) needed for running the program #include <iostream> #include <ctime> using namespace std; // declaring a prototype functions int rng(); int winorlose(); int budgetcalculator(char, float, float); // starting the main function int main() { float budget = 10000; float bet; char winlose; cin>>bet; do { winlose = winorlose(); }while(winlose=='n'); budget = budgetcalculator(winlose, budget, bet); cout<<budget<<endl; return 0; } // end of the main function int rng() { // declaring local variables const int n = 6; // the number of faces of the dice int x1, x2, sum; // the 2 number generated by the RNG (x1 & x2), and their sum srand ( (unsigned) time (NULL) ); //Initialize RNG x1 = rand( ) % n + 1; // Generate a number from the sequence cout<<"The 2 generated numbers are: "<<x1<<" "; // Print it x2 = rand( ) % n + 1; // Generate another number from the sequence cout<<"& "<<x2<<endl; // Print it sum = x1 + x2; // summing the two randomly generated numbers cout<<"Thir sum is: "<<sum<<endl; return sum; } //end of function int winorlose() { int dicesum; dicesum = rng(); // if statment for checking if the sum of the 2 randomly generated numbers is 7 or 11 if((dicesum==7) || (dicesum==11)) return 'w'; else if((dicesum==2) || (dicesum==3) || (dicesum==12)) return 'l'; else return 'n'; // end of if statment } int budgetcalculator(char state, float credit, float moneybet) { if(moneybet<=credit) if(state=='w') credit += moneybet; else if(state=='l') credit -= moneybet; return credit; }