"Write a Java program which asks the user to enter five numbers.
The program should prevent the user from entering the same number more than once. It should also print to the screen the numbers already entered by the user."
The output should become:
Please, enter a number: 3
List: 3
Please enter a number: 16
List: 3 16
Please enter a number: 16
Number is already in the list !!! Try again !!!
List: 3 16
Please enter a number: 23
List: 3 16 23
Of course the numbers don't have to be exactly the ones I said. Please help? What I have so far:
Scanner in = new Scanner(System.in);
System.out.print("Please, enter a number: ");
int num[] = new int[5];
for (int i = 0; i < num.length; i++)
{
num[i] = in.nextInt();
}
Programming is hard.. I tried to do separate user inputs and listed them that way but I have no idea how to check if a number has already been entered.
Help would be very much appreciated!