2024-10-21

알파벳 a ~ c 중에서 하나를 선택하세요. :
c
선택한 과일은 cherry 입니다.
package basic;
import java.util.Scanner;
public class SwitchCaseExam_13 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("알파벳 a ~ c 중에서 하나를 선택하세요. : ");
char fruit = sc.next().charAt(0);
switch(fruit) {
case 'a' :
System.out.println("선택한 과일은 apple 입니다.");
break;
case 'b' :
System.out.println("선택한 과일은 banana 입니다.");
break;
case 'c' :
System.out.println("선택한 과일은 cherry 입니다.");
break;
default :
System.out.println("선택한 과일이 없습니다.");
}
sc.close();
}
}'Java > 기초 내용 정리' 카테고리의 다른 글
| Java(Control)_While_15 (0) | 2024.10.22 |
|---|---|
| Java(Control)_SwitchCase_14 (0) | 2024.10.21 |
| Java(Control)_SwitchCase_12 (0) | 2024.10.21 |
| Java(Control)_IfElseIf_11 (1) | 2024.10.21 |
| Java(Control)_IfElseIf_10 (0) | 2024.10.21 |