Answer by santhosh for Converting an if-else-if statement into a switch...
/* Just change choice to 1 * if you want 2 or 3 or 4 * just change the switch(2 or 3 or 4) */switch(1){ case 1: System.out.println("You selected 1."); break; case 2: case 3: System.out.println("You...
View ArticleAnswer by MeIr for Converting an if-else-if statement into a switch statement...
import java.util.Scanner;public class ifToSwitchConversion {public static void main(String [] args) { // Declare a Scanner and a choice variable Scanner stdin = new Scanner(System.in); int choice = 0;...
View ArticleAnswer by arshajii for Converting an if-else-if statement into a switch...
You probably want something like:switch (choice) { case 1: System.out.println("You selected 1."); break; case 2: case 3: // fall through System.out.println("You selected 2 or 3."); break; case 4:...
View ArticleAnswer by Idan Arye for Converting an if-else-if statement into a switch...
switch(choice){ case 1: System.out.println("You selected 1."); break; case 2: case 3: System.out.println("You selected 2 or 3."); break; case 4: System.out.println("You selected 4."); break; default:...
View ArticleConverting an if-else-if statement into a switch statement in java
I'm having trouble turning this program from an if-else-if statement into a switch statement. Any help would be appreciated.import java.util.Scanner;public class ifToSwitchConversion { public static...
View Article
More Pages to Explore .....