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

1 Expert Approved Answer
Step: 1 Unlock

CODE File Name Seasonsjava import javautilScanner public class Seasons public static void mainString ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Starting Out With Java From Control Structures Questions!