Advertisement
Guest User

Untitled

a guest
May 4th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication8;
  7.  
  8. import java.util.Arrays;
  9. import java.util.Random;
  10.  
  11. /**
  12.  *
  13.  * @author Fabs
  14.  */
  15. public class JavaApplication8 {
  16. static Integer[] numbers = new Integer[5];
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         // TODO code application logic here
  22.         Random preguntaAzar = new Random();
  23.         //
  24.        
  25.        
  26.         for(int i = 0; i < 5; i++) {
  27.            
  28.             int pregunta = preguntaAzar.nextInt(5);
  29.             System.out.println("Random es:"+pregunta);
  30.             while(Arrays.asList(numbers).contains(pregunta)) {
  31.                
  32.                pregunta = preguntaAzar.nextInt(5);
  33.                System.out.println("Num:"+pregunta);
  34.                
  35.             }
  36.             numbers[i] = pregunta;
  37.             if (pregunta == 0) {
  38.             System.out.println("Se ejecuto la 0");
  39.             } else if (pregunta == 1) {
  40.             System.out.println("Se ejecuto la 1");
  41.             } else if(pregunta == 2){
  42.             System.out.println("Se ejecuto la 2");
  43.             } else if(pregunta == 3){
  44.             System.out.println("Se ejecuto la 3");
  45.             }else if(pregunta == 4){
  46.             System.out.println("Se ejecuto la 4");
  47.             }
  48.         }
  49.     }
  50.    
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement