consider this simple logic
longestRun = 0;
currentRun = 0;
for (int i = 0; i < FLIPS; i++)
{
if(Randomizer.nextBoolean())
{
System.out.println("Heads");
// headFlips++; - not used
currentRun ++;
}
else
{
System.out.println("Tails");
// tailFlips++; - not used
longestRun = Math.max (longestRun, currentRun);
currentRun = 0;
}
}
// need to do after the loop too
longestRun = Math.max (longestRun, currentRun);
System.out.println("Longest streak of heads: " +longestRun);