• Lenguaje

    Java usando Scanner

  • Descripción

    Simule el lanzamiento de un dado. Si el dado muestra un valor par, entonces gana, caso contrario pierde. Utilice números aleatorios.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.Random;

public class LanzamientoDeUnDado {

    public static void main(String[] args) {
        int lanzamiento;
        Random rand = new Random();
        lanzamiento=1+rand.nextInt(6);
        if(lanzamiento%2==0)
            System.out.println("Gana");
        else
            System.out.println("Pierde");
        System.out.println("Valor de lanzamiento: " + lanzamiento);
    }

}