boosledorf
JCHJava Community | Help. Code. Learn.
•Created by boosledorf on 4/9/2025 in #java-help
confused about a question on my practice exam with switch and case
public class Test {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
switch (i) {
case 1:
case 2:
System.out.print("A");
if (i % 2 == 0) {
System.out.print("B");
}
break;
case 3:
case 4:
System.out.print("C");
if (i == 4) {
System.out.print("D");
} else {
System.out.print("E");
}
break;
case 5:
System.out.print("F");
break;
case 6:
case 7:
System.out.print("G");
if (i % 3 == 0) {
System.out.print("H");
}
break;
}
}
}
}
12 replies