[SOLVED] SOLVED:Switch Statement

10.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

rar file icon witchErrors.rar (3.1 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (3 votes)

Switch Statement Open the provided file SwitchErrors.java. The Java source code is shown below. The program evaluates an integer entered by the user and displays the color assigned to the integer. Compile the program. The program has several syntax and logic errors. Fix the syntax errors and compile and run the program. Does the program run as you expected? Locate and correct the errors in the program logic. Be sure to make use of the debugger available in Eclipse to help identify errors. package edu.ilstu; import java.util.Scanner; public class SwitchErrors { public static void main(String[] args) { Scanner keyboard = new Scanner(System.out); System.out.println(“Key: 1=blue, 2=red, 3=green”); System.out.print(“Enter a number and I’ll return “); System.out.print(” the corresponding color. “); number = keyboard.nextInt(); switch(number) { case 1: System.out.println(“You chose red!”); break; case 2: System.out.println(“You chose blue!”); break; case 3: System.out.println(“You chose green!”); default: System.out.println(“Color not available!”); break; } } }

  • witchErrors.rar