title: Creating an automated Lottery
body: <p>I would like to program an automated Lottery "script" which creates 2 Arrays: one holding the Lottery numbers and another holding the guess itself. Then, I check if eg. lottery[] holds numbers of the guess[], if the numbers are equal and he hits the 6 right numbers in the loop, I want the console to print out how many tries he needed. </p>
  
  <pre><code>public static void main(String[] args) {
  
      int[] lottery = new int[6];
      int[] tipp1 = new int[6];
      int randomNum;
      int tipp;
  
      for (int i = 0; i &lt; 6; i++) {
          randomNum = (int) (Math.random() * 49 + 1); // Random number created here.
          for (int x = 0; x &lt; i; x++) {
              if (lottery[x] == randomNum) // Here, code checks if same random number generated before.
              {
                  randomNum = (int) (Math.random() * 49 + 1);// If random number is same, another number generated.
                  x = -1; // restart the loop
              }
          }
          lottery[i] = randomNum;
          System.out.print(lottery[i] + " ");
      }
  
      System.out.println(" ");
  
      for (int c = 0; c &lt; 6; c++) {
          tipp = (int) (Math.random() * 49 + 1); // Random number created here.
          for (int xy = 0; xy &lt; c; xy++) {
              if (tipp1[xy] == tipp) // Here, code checks if same random number generated before.
              {
                  tipp = (int) (Math.random() * 49 + 1);// If random number is same, another number generated.
                  xy = -1; // restart the loop
              }
          }
          tipp1[c] = tipp;
          System.out.print(tipp1[c] + " ");
      }
      if (lottery.equals(tipp1)){
          System.out.print("HIT!");
      }
  }
  }
  </code></pre>
  
  <p>Is there a way to do this?</p>