title: A program that counts that maximum streak of heads and tails
body: <p>This is what I have so far, but I can't seem to figure out how to do it. I am so far only able to store the total amounts of heads and tails flipped.</p>
  <pre><code>import java.util.*;
  class Main {
      public static void main(String[] args) {
          int heads = 0, tails = 0;
          int usernum;
          int hc=0;
  
          Scanner scan = new Scanner(System.in);
          Coin myCoin = new Coin();
          System.out.println(&quot;The number flips: &quot;);
          usernum=scan.nextInt();
          for (int count = 1; count &lt;= usernum; count++)//this is where I'm having the most trouble, as I can't figure out how to store the greatest streak for heads and tails.
          {
              myCoin.flip();//generates either 1 or 0
              if (myCoin.isHeads())//checks if the integer is equal to 1 (which is heads in this case)
              {
                  heads++;
                  System.out.println(&quot;Heads&quot;);
                  if (heads&gt;=hc)
                     hc++;
              }else{
                  tails++;
                  hc=0;
                  System.out.println(&quot;Tails&quot;);
              }
          }
          System.out.println(&quot;Heads: &quot; + heads);
          System.out.println(&quot;Tails: &quot; + tails);
      }
  }
  </code></pre>