Question: Create an IPO and algorithm chart for the following code: import java.util.Scanner;//import scanner public class SwitchDemo { //start class public static void main(String[] args) {//start
Create an IPO and algorithm chart for the following code:
import java.util.Scanner;//import scanner
public class SwitchDemo { //start class public static void main(String[] args) {//start main method Scanner keyboard = new Scanner(System.in); System.out.println("Enter number of ice cream flavors:");//prompt user for value int numberOfFlavors = keyboard.nextInt( );//next number entered will be read by the program switch (numberOfFlavors) { //start switch case 32: System.out.println("Nice selection.");//if 32 is entere "Nice Selection will pop out break; case 1: //if 1 is enetered the output will be "I bet it's vanilla." System.out.println("I bet it's vanilla."); break; case 2: case 3: case 4: System.out.println(numberOfFlavors + " flavors");//for all of these cases, 2,3,and 4 it will say that number of flavors is acceptable System.out.println("is acceptable."); break; default://default will be the case dor any input not specified above System.out.println("I didn't plan for"); System.out.println(numberOfFlavors + " flavors."); break; }//end switch }//end main method }//end of class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
