daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Apr 22nd, 2018 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.util.Random;
  3. public class Rand {
  4.     int[] rad;
  5.    
  6.    
  7. int[] random_rand() {
  8.    
  9.     int Rand[]=new int[7];
  10.     int i=0,j=0;
  11.     boolean Same=false;
  12. //Get 7 random numbers
  13.     System.out.println("\n7 random numbers:");
  14.     for(i=0;i<7;i++) {
  15.             Random rand = new Random();
  16.             Rand[i]=rand.nextInt(39);
  17.             System.out.print(Rand[i]+" ");
  18.             }
  19. // continues on the other side
  20. //Check if they are different from eachother
  21.     for(i=0;i<7;i++) {
  22.         for(j=0;j<i;j++) {
  23.             do{
  24.                 if(Rand[i]==Rand[j]){
  25.                     Random rand = new Random();
  26.                     Rand[i]=rand.nextInt(39);
  27.                     Same=true;
  28.                 }
  29.                 else{Same=false;}
  30.             }
  31.             while(Same==true);
  32.         }
  33.     }
  34.     return Rand;
  35.     }
  36. }
  37.  
  38.  
  39. ______________________________________________________________________________________
  40.  
  41.  
  42. import java.util.Scanner;
  43.  
  44.  
  45. public class battreanjonis {
  46.      static Scanner scn = new Scanner(System.in);
  47.     /**
  48.      * @param args
  49.      */
  50.     public static void main(String[] args) {
  51.         // TODO Auto-generated method stub
  52.         Rand r = new Rand();
  53.         r.random_rand();
  54.         r.random_rand();
  55.         r.random_rand();
  56.         r.random_rand();   
  57.         while(jonej()){
  58.             Rand r1 = new Rand();
  59.             r1.random_rand();
  60.         }
  61.     }
  62.    
  63.     static boolean jonej(){
  64.         System.out.println("Spela lotto? 1/0");
  65.         if(scn.nextInt()==1){
  66.             return true;
  67.         }
  68.         return false;
  69.        
  70.     }
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top