Question: Given the following table of values: complete the switch statement in the Java program included below to produce the expected output Fruit=0 (Unknown) Fruit=1 (Apple)
Given the following table of values:
complete the switch statement in the Java program included below to produce the expected output
Fruit=0 ("Unknown") Fruit=1 ("Apple") Fruit=2 ("Banana") Fruit=3 ("Grape") Fruit=4 ("Orange") Fruit=5 ("Tangerine")
Do not modify any of the code outside of the switch statement.
Do not declare any additional variables.
Your solution must use the named constants provided for the numeric and String values of the fruit.
Your output must match the expected output exactly as specified, including the parentheses and quotation marks.
Your switch statement must be indented and aligned consistently and correctly based on course conventions.
public class FruitSwitch { public static void main(String[] args) { // constants for fruit values and names final int MAX_FRUIT = 5; final int FRUIT_APPLE = 1, FRUIT_BANANA = 2, FRUIT_GRAPE = 3, FRUIT_ORANGE = 4, FRUIT_TANGERINE = 5; final String FRUITNM_APPLE = "Apple", FRUITNM_BANANA = "Banana", FRUITNM_GRAPE = "Grape", FRUITNM_ORANGE = "Orange", FRUITNM_TANGERINE = "Tangerine", FRUITNM_UNKNOWN = "Unknown"; String output = ""; for (int fruit = 0; fruit
// your code goes here
} System.out.println(output); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
