CoinsToss 4-25

posted Mar 5, 2014, 10:05 AM by dldar masud   [ updated Mar 5, 2014, 10:05 AM by Karwan Jacksi ]

package cointoss;

import java.util.Random;
/*
 This program simulates 10 tosses of a coin.
 */
public class CoinToss {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        // Create a Random object to generate random numbers.
        Random rand = new Random();
        
         // Simulate the coin tosses.
         for (int count = 0; count < 10; count++)
         {
           if (rand.nextInt(2)== 0)
           System.out.println("Tails");
           else
           System.out.println("Heads");
         }
       
    }
}

ċ
CoinToss.java
(1k)
Karwan Jacksi,
Mar 5, 2014, 10:05 AM
Comments