title: Which number showed up most often in a array
body: <p>This code is for a coin flipping program. Where a coin is flipped 1000 times and the program shows you how many times each number from 1-10 appeared those 1000 times, which side of the coin came up more often and which number showed up more often.</p>
  <p>Currently, the code shows how many times each number from 1-10 appeared in those 1000 flips and which side of the coin came up more often, but I am struggling with how to get the program to show which number showed up more often.</p>
  <p>I need the program to show which number from 1-10 showed up the most during those 1000 flips.</p>
  <pre><code>package so;
  
  import java.util.Random;
  
  public class CoinFlipping {
  
      public static void main(String[] args) {
          Random randomNumbers = new Random(); // random number generator
  
          int frequency1 = 0, frequency2 = 0, frequency3 = 0, frequency4 =
          0, frequency5 = 0, frequency6 = 0, frequency7 = 0, frequency8 = 0,
          frequency9 = 0, frequency10 = 0;// stores individual frequencies
  
          int number; // stores most recently generated value
  
          // summarize results of 1000
          for (int col = 1; col &lt;= 1000; col++) {
              number = 1 + randomNumbers.nextInt(10); // numbers from 1 to 10
  
  
              // determine values 1-10 and increment appropriate counter
              switch (number) {
                  case 1:
                      ++frequency1; // increment the 1s counter
                      break;
                  case 2:
                      ++frequency2; // increment the 2s counter
                      break;
                  case 3:
                      ++frequency3; // increment the 3s counter
                      break;
                  case 4:
                      ++frequency4; // increment the 4s counter
                      break;
                  case 5:
                      ++frequency5; // increment the 5s counter
                      break;
                  case 6:
                      ++frequency6; // increment the 6s counter
                      break;
                  case 7:
                      ++frequency7; // increment the 7s counter
                      break;
                  case 8:
                      ++frequency8; // increment the 8s counter
                      break;
                  case 9:
                      ++frequency9; // increment the 9s counter
                      break;
                  case 10:
                      ++frequency10; // increment the 10s counter
                      break;
  
  
              }
          }
  
          System.out.println(&quot;Number \t Times Landed&quot;);
          System.out.printf(&quot;1\t%d\n2\t%d\n3\t%d\n4\t%d\n5\t%d\n6\t%d\n7\t%d\n8\t%d\n9\t%d\n10\t%d\n&quot;, frequency1, frequency2, frequency3, frequency4, frequency5, frequency6, frequency7, frequency8, frequency9, frequency10);
          int even = 0, odd = 0;//stores even or odd totals
          even = frequency2 + frequency4 + frequency6 + frequency8 + frequency10;
  
          odd = frequency1 + frequency3 + frequency5 + frequency7 + frequency9;
  
          System.out.println(&quot;\n Heads: &quot; + even + &quot;\n Tails: &quot; + odd);
  
      }
  
  }
  </code></pre>