Guest User

Untitled

a guest
Mar 26th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. // Imports
  2. import java.util.Random;
  3.  
  4. public class LotteryProgram
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         int[] combo = {0, 0, 0, 0, 0, 0};
  9.         Random lotteryBall = new Random();
  10.          
  11.         for (int currentNum = 0; currentNum < 6; currentNum++) { // For Each Number
  12.             combo[currentNum] = lotteryBall.nextInt(49)+1;
  13.             for (int checkDuplicate = currentNum - 1; checkDuplicate >= 0; checkDuplicate--) { // Check For Duplicates
  14.                 while (combo[currentNum] == combo[checkDuplicate]) { // Run a Change, Reset Duplicate Check
  15.                     combo[currentNum] = lotteryBall.nextInt(49)+1;
  16.                     // System.out.println("Changed Spot " + (x+1)); // Tell Duplicate
  17.                     checkDuplicate = currentNum - 1;
  18.                 }
  19.             }
  20.         }
  21.          
  22.         // Print Combination
  23.         System.out.println("Combination: ");
  24.         for (int x = 0; x < 6; x++)
  25.         {
  26.             System.out.print(combo[x] + " ");
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment