title: C++ programming Craps game simulation
body: <p>Write a C++ program that simulates the casino game of craps. These are the rules of the game:
  •   If a player throws a 7 or 11 (sum of two dice) on the first roll, the player wins the game.
  •   If a player throws a 2, 3 or 12 (sum of two dice) on the first roll, the player loses the game.
  •   If a player throws a 4, 5, 6, 8, 9 or 10 (sum of two dice) on the first roll, s(he) neither wins nor loses but creates a “point.” If this is the case, the player keeps rolling the dice until the point (4, 5, 6, 8, 9 or 10) is thrown again, and the player wins the game. However, if the player throws a 7 (sum of two dice) before the “point” is thrown, the player loses the game.</p>
  
  <p>You will create a function called  rollDice  that will, when called, roll two dice and return a random number between 2 and 12. Each time  rollDice  is called, the program should output the result of the roll</p>
  
  <p>The program will ask the player ” Another game? Y(es) or N(o)?” and terminate whenever any key other than Y or y is pressed.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  int main()
  {
  int dice1, dice2 = 0; 
  int rollDice;
  char repeat = 'y'; 
  
  cout &lt;&lt; "**********************************************************"&lt;&lt; endl;
  cout &lt;&lt; "********   Welcome to the Kyung Bae Choi Casino   ********"&lt;&lt; endl;
  cout &lt;&lt; "********* Step up to the table and place your bets! ******"&lt;&lt; endl;
  cout &lt;&lt; "**********************************************************"&lt;&lt; endl;
  
  while (repeat == 'y' || repeat == 'Y') 
  {                                                   
      dice1 = rand() % 6 + 1;
      dice2 = rand() % 6 + 1; 
      rollDice = dice1 + dice2;
  
      cout &lt;&lt; "Your rolled " &lt;&lt; rollDice;
      if (rollDice == 7 || rollDice == 11)
      {
          cout &lt;&lt; ". Winner !" &lt;&lt; endl ;
      } 
  
      else if (rollDice == 2 || rollDice == 3 || rollDice == 12)
      {
          cout  &lt;&lt; ". You lose!" &lt;&lt; endl; 
      }
  
      else if (rollDice == 4 || rollDice == 5 ||rollDice == 6 ||rollDice == 8 || rollDice == 9 || rollDice == 10)
        {     
          dice1 = rand() % 6 + 1;
          dice2 = rand() % 6 + 1; 
      int sum2 = dice1 + dice2;
  
       if( sum2 == rollDice )
              {
                  cout &lt;&lt; ". Winner !" &lt;&lt; endl;
                  break;
              } 
      else if( sum2 == 7 )
              {
                  cout &lt;&lt; ". You Lose!" &lt;&lt; endl;
                  break;
              }
    }
  cout &lt;&lt;"Another game? Y(es) or N(o)"  &lt;&lt; endl;
      cin &gt;&gt; repeat;
  
  while (repeat == 'n' || repeat == 'N') 
  {
  cout &lt;&lt;  "Thank you for playing!"&lt;&lt; endl;
  }
  return 0;
  }
  }
  </code></pre>
  
  <p>This does output only 7. so, it keep saying Your rolled 7. Winner !
  Another game? Y(es) or N(o). And, if i put y, the program ends. or if i put n, the program output the "thank you for playing!" endlessly. </p>
  
  <p>what is problem??</p>
  
  <p>How can I make it continually re-rolling the dice until the player rolls the winning "point" or rolls a seven.</p>