import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int randnum = 0;
boolean lose = false;
Random gen = new Random();
Scanner scan = new Scanner(System.in);
System.out.println("Enter desired numbers to be drawn");
int print = scan.nextInt();
System.out.println("Enter desired numbers on dice");
int dice = scan.nextInt();
System.out.println("Enter your lucky numbers");
int[] numbers = new int[print]; // int and print rhyme
for(int i=0; i<print;i++){
numbers[i] = scan.nextInt();
}
for(int counter=1; counter<=print;counter++){
randnum = 1+gen.nextInt(dice);
System.out.println(randnum + " ");
System.out.println();
if (randnum == numbers[counter - 1]){
lose = false;
} else {
lose = true;
}
if (lose == true){
System.out.println("Bad luck!");
}
if (lose == false){
System.out.println("Winner winner chicken dinner!");
}
}
}
}
I am making a simple lotto game. If I correctly guess the numbers I will still get the losing outcome unless it was the last number I guessed. How do I compare randnum
to all numbers that were inputted?