title: Boolean method that returns an int value;
body: <p>I am teaching myself Java, and I created a program to simulate a game of craps. I have the entire game in a Boolean method. Everything works fine, but I want to count every time the user wins. What is the best way to count these wins, and then print them?</p>
  <p>Here is my code:</p>
  <pre><code>import java.util.Random;
  
  public class game{
  
  public static void main(String[] args) {
      Random rand = new Random();
      for(int i = 0; i &lt;= 10; i++){
          craps(rand);
      }
  }
  
  public static boolean craps(Random randomGen){
      int roll1 = randomGen.nextInt(6) + 1;
      int roll2 = randomGen.nextInt(6) + 1;
  
      int sum = roll1 + roll2;
      int sumRepeat = sum;
      int count = 0;
  
  
      String win = &quot;you win&quot;;
      String lose = &quot;you lose&quot;;
      String point = &quot;point=&quot;;
  
      if(sum == 7 || sum == 11){
          System.out.printf(&quot;[%d,%d] %d %s\n&quot;,roll1,roll2,sum,win);
          count++;
          return true;
      }
      else if(sum == 2 || sum == 3 || sum == 12){
          System.out.printf(&quot;[%d,%d] %d %s\n&quot;,roll1,roll2,sum,lose);
          return false;
      }
      else{
          System.out.printf(&quot;[%d,%d] %s %d&quot;,roll1,roll2,point,sum);
          int roll3 = randomGen.nextInt(6) + 1;
          int roll4 = randomGen.nextInt(6) + 1;
          int sum2 = roll3 + roll4;
          do{
              roll3 = randomGen.nextInt(6) + 1;
              roll4 = randomGen.nextInt(6) + 1;
              sum2 = roll3 + roll4;
              if(sum2 == sumRepeat){
                  System.out.printf(&quot;[%d,%d] %d %s\n&quot;,roll3,roll4,sum2,win);
                  count++;
                  return true;
              }else{
                  System.out.printf(&quot;[%d,%d]&quot;,roll3,roll4);
              }
          }
          while(sum2 != 7);{
              System.out.printf(&quot;[%d,%d] %d %s\n&quot;,roll3,roll4,sum2,lose);
              return false;
          }
      }
  }
  }
  </code></pre>
  <p>I have tried to return the count variable but I get an error saying I can't return an int value from a Boolean method which I expected. But I also tried to print out the count value with <code>System.out.println();</code> But I can't find a place in the code to put it since I always get an error stating that the println is unreachable code.</p>
  <p>Any help would be appreciated. Thanks!</p>
  <p><strong>Here is the output of the program</strong></p>
  <blockquote>
  <p>[1,6] 7 you win</p>
  <p>[2,4] point= 6[3,6][3,3] 6 you win</p>
  <p>[3,3] point= 6[5,1] 6 you win</p>
  <p>[6,1] 7 you win</p>
  <p>[6,3] point= 9[5,1][3,5][2,6][6,4][5,6][1,5][6,3] 9 you win</p>
  <p>[3,3] point= 6[1,5] 6 you win</p>
  <p>[5,1] point= 6[1,5] 6 you win</p>
  <p>[2,2] point= 4[6,4][3,3][3,4][3,4] 7 you lose</p>
  <p>[4,5] point= 9[6,4][5,1][1,2][6,2][1,5][3,5][6,5][1,5][5,2][5,2] 7 you lose</p>
  <p>[2,2] point= 4[5,3][5,6][6,4][3,2][6,5][3,6][4,4][4,2][4,3][4,3] 7 you lose</p>
  <p>[6,6] 12 you lose</p>
  <p>You won 11 time(s).</p>
  </blockquote>