Question: Complete the following program skeleton by writing a switch statement that displays one if the user has entered 1, two if the user has entered
Complete the following program skeleton by writing a switch statement that displays “one” if the user has entered 1, “two” if the user has entered 2, and “three” if the user has entered 3. If a number other than 1, 2, or 3 is entered, the program should display an error message.
import java.util.Scanner;
public class CheckPoint
{
public static void main(String[] args)
{
int userNum;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter one of the numbers " +
"1, 2, or 3: ");
userNum = keyboard.nextInt();
//
// Write the switch statement here.
//
}
}
Step by Step Solution
3.45 Rating (171 Votes )
There are 3 Steps involved in it
CODE File Name Seasonsjava import javautilScanner public class Seasons public static void mainString ... View full answer
Get step-by-step solutions from verified subject matter experts
