Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class SideLandingExperiment {
- static boolean coinOnSide = false;
- static int timesTried = 0;
- public static void main(String[] args) {
- while (coinOnSide == false) {
- Random rand = new Random();
- timesTried++;
- System.out.println("Try number" + timesTried);
- int result = rand.nextInt(6001);
- if (result == 0) {
- System.out.println("side");
- System.out.println("It took " + timesTried
- + " tries to get the coin to land on its side");
- coinOnSide = true;
- }
- else if (result > 0) {
- if (result < 3000) {
- System.out.println("heads");
- }
- }
- if (result > 3000) {
- System.out.println("tails");
- }// ends if
- }// ends loop
- }// ends method main
- }// ends Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement