[JAVA] ch04-08. SWITCH ~ CASE 문 3
·
JAVA/예제
public class Ex08 { public static void main(String[] args){ int score = 3; switch(score*100){ case 100: System.out.println("score: 100"); case 200: System.out.println("score: 200"); case 300: System.out.println("score: 300"); case 400: System.out.println("score: 400"); default: System.out.println("none"); } } }
[JAVA] ch04-06. SWITCH ~ CASE 문
·
JAVA/예제
public class Ex06 { public static void main(String[] args){ int score = (int)(Math.random() * 10)+1; // 시작값이 1 시작값으로부터 10개 중 랜덤으로 1개 int tmp = score * 100; switch(tmp){ case 100: System.out.printf("score %d : bicycle", tmp); break; case 200: System.out.printf("score %d : TV", tmp); break; case 300: System.out.printf("score %d : Aircon", tmp); break; default: System.out.println("no price"); } } }