Question: I have the switch statement made, but for some reason my code still allows partially-spelled names of the flavors (Oran, Cher, Li) fulfill the outputs

 I have the switch statement made, but for some reason my

I have the switch statement made, but for some reason my code still allows partially-spelled names of the flavors ("Oran", "Cher", "Li") fulfill the outputs when they should still be "Invalid flavor".

1. Write a program called Flavors that prompts the user to enter a flavor represented by the String "o" or "O" for Orange, "c" or "C" for Cherry, and T or "L" for Lime. Use a switch statement to output "Orange", "Cherry, "Lime, or "Invalid flavor based on the user input. Any input other than o, O, C, C, I, or L should result in Invalid flavor, For example, $ java Flavors Flavor (0-range, C-herry, L-ime): o Orange $ java Flavors Flavor (0-range, C-herry, L-ime): 0 Orange $ java Flavors Flavor (0-range, C-herry, L-ime): orange Invalid flavor $ java Flavors Flavor (0-range, C-herry, L-ime): G Invalid flavor

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!