Advertisement
TheSTRIG

PRD

Oct 25th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class ajjajj {
  5.     public static int rngCounter()
  6.     {
  7.         int a;
  8.        
  9.         Random rand = new Random();
  10.         a = rand.nextInt(99);
  11.         return a;
  12.     }
  13.    
  14.     public static void PRD()
  15.     {
  16.         Scanner in = new Scanner(System.in);
  17.         String rngg;
  18.         int[] noprocArray;
  19.         noprocArray = new int[100];
  20.        
  21.         Integer p;
  22.         int tryCounter = 0;
  23.        
  24.         boolean randomLagi = true;
  25.         boolean seratus = true;
  26.        
  27.         while(tryCounter != 100)
  28.         {
  29.             p = rngCounter();
  30.             if(p != null)
  31.             {
  32.                 while(randomLagi)
  33.                 {
  34.                     p = rngCounter();
  35.                     for(int i = 0; i < noprocArray.length; i++)
  36.                     {
  37.                         if(tryCounter == 0)
  38.                         {
  39.                             break;
  40.                         }
  41.                         else if(p == noprocArray[i])
  42.                         {
  43.                             randomLagi = true;
  44.                             break;
  45.                         }
  46.                         else
  47.                         {
  48.                             noprocArray[i] = p;
  49.                             randomLagi = false;
  50.                         }
  51.                     }
  52.                     break;
  53.                 }
  54.                 if(p < 20)
  55.                 {
  56.                     System.out.printf("Angka Random: %d\n", p);
  57.                     System.out.println("proc");
  58.                     noprocArray = new int[100];
  59.                     //tryCounter++; siapa tau
  60.                     System.out.println("RNGG!");
  61.                     System.exit(0);
  62.                 }
  63.                 else
  64.                 {
  65.                     System.out.printf("Angka Random: %d\n", p);
  66.                     System.out.println("noproc");
  67.                     tryCounter++;
  68.                     System.out.println("Scrubz, press Enter key to try again...");
  69.                     rngg = in.nextLine();
  70.                 }
  71.             }
  72.         }
  73.     }
  74.    
  75.     public static void main(String[] args){
  76.         PRD();
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement