Must be done in Java. -Create a console (standalone) application that allows a u
ID: 3824203 • Letter: M
Question
Must be done in Java.
-Create a console (standalone) application that allows a user to enter 5 numbers.
-Ask the user to enter a number that is greater than zero and less than 49.
-If a user enters a number that is less than zero, or greater than 48, give them a message telling them to re-enter a number.
-Each of these five numbers that the user enters must be different. If a user enters the same number more than once, give them a message saying the number must be different.
-Here is a sample output for the first 3 numbers, but remember that there are 5 all together:
lease enter number 1 which should be 0 and less than 49 Number 1 must be less than 49 Please enter number1 which should be 0 and less than 49 please enter number2 which should be 0 and less than 49 Number 2 must be greater than zero Please enter number2 which should be 0 and less than 49 mber2 must be less than 49 Please enter number2 which should be e and less than 49 Number2 must be different from number1 Please enter number2 which should be 0 and less than 49 Please enter number3 which should be 0 and less than 49 Number must be greater than zero Please enter number3 which should be 0 and less than 49 Number3 must be less than 49 Please enter number3 which should be 0 and less than 49 Number 3 must be different from numbers 1 and 2. Please enter number3 which should be 0 and less than 49 Number 3 must be different from numbers 1 and 2. Please enter number3 which should be 0 and less than 49Explanation / Answer
public static void main( string args[])
{
int num;
Scanner in= new Scanner (System.in);
for(int i=0;i<5;i++)
{
System.out.println("enter num"+i" which should be < 49 and > 0");
int number[i]=in.nextInt();
if( number[i]<49) System.out.println("enter number than 49");
else if(number[i]>0) System.out.println("enter number greater than 0");
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.