Pineapple
Just Smile.
- Reaction score
- 576
I am having problems with this Java loop. I am using a for loop to simulate a coin flip.
The probelm is that I need it to loop 10 times. So you see 10 results. now, it only shows it once.
I don't know if this belongs here or else where, but this area seemed most appropriate.
The probelm is that I need it to loop 10 times. So you see 10 results. now, it only shows it once.
Code:
import java.util.Random;
public class XCoin{
public static void tenFlip( ){
int result;
for (int i = 0; i < 10; i++);
{
Random rand = new Random();
result = rand.nextInt(2)+1;
if (result == 1){
System.out.println("H");
}
else {
System.out.println ("T");
}
}
}
}
I don't know if this belongs here or else where, but this area seemed most appropriate.