Random coin flip application
Application for 10 random coin flips. At the end of the application I just want to display the percentage of the heads flipped and percentage of tails flipped. Can someone point me in a right direction please?
Code:
//import statements
import java.util.*;
public class FlipCoin
{
public static void main(String [] args)
{
//declare variables
double flip;
int count = 0;
int countHeads = 0;
int countTails = 0;
int percentHeads;
int percentTails;
//Loop
for(int x = 0; x <= 10;x = x++)
{
x = x + 1;
//flip
flip = Math.random();
//if statement
if( flip <= .5)
{
flip = countHeads;
countHeads = countHeads + 1;
percentHeads = countHeads * 10;
}
else
{
flip = countTails;
countTails = countTails + 1;
percentTails = countTails * 10;
System.out.println("Heads was flipped " + percentHeads + " percent of the time.");
System.out.println("Tails was flipped " + percentTails + " percent of the time.");
}
count = count +1;
}//End Loop
}//End Main
}//End Class