Design a java program that uses the switch statement and asks the user to select
ID: 3759608 • Letter: D
Question
Design a java program that uses the switch statement and asks the user to select one of three television models. The program should provide a description of the models. Using the fall-through capability of the switch statement, display the model chosen, the description, and the price. The user should make a selection by model number: Model 100 comes with remote control, timer, and stereo sound and costs $1000. Model 200 comes with all the features of model 100, plus picture in picture; it costs $1200. Model 300 comes with all features of model 200 plus HDTV, flat screen, and 16x9 aspect ratio; it costs $2400. USE THE FOLLOWING DESCRIPTION AND PROMPT FOR THE PROGRAM. 1. This program asks the user to enter a television model #. 2. The description of the model chosen will be displayed. 3. Please enter the model number chosen. 4. Model 100 comes with remote control, timer and stereo sound and costs $1000. 5. Model 200 comes with all features of model 100 .......... 6. Model 300 ........
Explanation / Answer
import java.util.*;
class television
{
public static void main(String args[])
{
Scanner o=new Scanner(System.in);
System.out.println("enter a television
model #");
int mno=Integer.parseInt(o.nextLine());
switch(mno)
{
case 100:
System.out.println
("This model "+mno+" comes with remote control, timer, and
stereo sound and costs $1000");
break;
case 200:
System.out.println
("This model "+mno+" comes with remote control, timer,
stereo sound plus picture in picture and costs $1200");
break;
case 300:
System.out.println
("This model "+mno+" comes with remote control, timer,
stereo sound,picture in picture plus HDTV, flat screen, and
16x9 aspect ratio; it costs $2400");
break;
default:
System.out.println
("Enter model # between 100-300 only");
break;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.