Question: Analyze complete the Java program that asks the user to enter a number between 1 and 3 and displays a message with the number.
Analyze complete the Java program that asks the user to enter a number between 1 and 3 and displays a message with the number. If an invalid number is entered an error message alerts the user: Invalid number entered. Use an If statement. Java Program: import java.util.*; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter a number between 1 and 3: "); int number = scan.nextInt(); if (number==1) System.out.println("You entered 1 "); else if (number==2) } ? }
Step by Step Solution
3.33 Rating (147 Votes )
There are 3 Steps involved in it
import javautilScanner public class Main public static void mainString args ... View full answer
Get step-by-step solutions from verified subject matter experts
