I have a problem using switch statement when I tried to deal with a special situation. For example, I have 3 cases: A, B, C.
When you use "case," use a switch statement first, and make sure you've got an initialized variable in it. Here's an example.
Use an initialized variable: i.e.
(String s=sc.nextLine();)
switch (s) {
case "Pepperoni":
System.out.println("Pepperoni? Nice choice. Please wait............Ding! Here's your pepperoni pizza. Enjoy, and thanks for using the Local Pizzeria!");
case "Cheese":
System.out.println("Cheese? Okay! Soft cheese it is! Please wait............Ding! Here's your cheese pizza. Enjoy, and thank you for using the Local Pizzeria!");
break;
case "Mushrooms":
System.out.println("Mushrooms? Veggie person, right? OK! Please wait............Ding! Here's your mushroom pizza. Enjoy, and thanks for using the Local Pizzeria!");
break;
case "Beef Bits":
System.out.println("Beef bits? Like meat? Alright! Please wait............Ding! Here's your beef bit pizza. Enjoy, and thank you for using the Local Pizzeria!");
break;
case "Spicy Buffalo Chicken":
System.out.println("Spicy buffalo chicken? Way to spice things up! Please wait............Ding! Here's your spicy buffalo chicken pizza. Enjoy, and thank you for using the Local Pizzeria!");
break;
case "Exit":
System.out.println("See you soon!");
}
}