hey guys, I created this program to "flip a coin"(only 50 times) I have successfully flipped the coin fifty times but I need to output how many heads and how many tails there are in the 50 flips. I think that i need to make heads and tails two separate variables and then do some sort of Count. Im just not quite sure how to do it.
Heres my code.
Heres my code.
Code:
public class coinFlip
{
public static void main(String[]args)
{
for (int counter=0; counter<=49; counter= counter++)
{
int flip= (int) (Math.random()*2)+1;
counter++;
int tails = 2;
int heads = 1;
if(flip== heads)
{
System.out.println("Flip #"+counter+": Heads");
}//end if
if(flip== tails)
{
System.out.println("Flip #"+counter+": Tails");
}//endif
}//end do
System.out.println("You rolled ");
}//end main
}//end public class
Last edited by a moderator: