Julss799 / PROJECTE1-DAM2

Projecte 1: Entrega 05/12/2022 - 07/12/2022
1 stars 0 forks source link

Fer el camp de BOOLEANS #7

Closed Julss799 closed 2 years ago

Formeinstein13 commented 2 years ago

import java.util.Random;

public class GeneradorBooleans {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    Random numero= new Random();
    boolean aleatori;
    int numeroAleatori=numero.nextInt(2);
    if (numeroAleatori==0){
        aleatori=false;
    }
    else {
        aleatori=true;
    }
    System.out.println(aleatori);
}

}

ghost commented 2 years ago

import java.util.Random;

public class booleans { public static void main(String[] args) { // TODO Auto-generated method stub Random numero= new Random(); boolean aleatori; //variable on es guarda boolean int numeroAleatori=numero.nextInt(2); //numeros aleatoris de 2 digits if (numeroAleatori==0){ //si es 0, sortira boolean false aleatori=false; } else { aleatori=true; //i si surt 1, sortira boolean true } System.out.println(aleatori); //mostrem per pantalla } }