lundi 22 février 2021

coin flipping simulator in java [duplicate]

/I want to simulate a coin flipping in java 50 times. However, the output always is "tail". Is there any problem with my code/

package chapter2;

import java.util.Random;

public class E7_coinflipping {
    public static void main (String[] args) {
        Random rand = new Random(50);
        boolean flip = rand.nextBoolean();
        System.out.print("outcome: ");
        System.out.println(flip? "tail" : "head");
    }
}
//output:

outcome: tail



Aucun commentaire:

Enregistrer un commentaire