본문 바로가기

프로그래밍/자바

[자바] 정올 123 : 선택제어문 - 형성평가4

728x90
반응형
SMALL
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Number? ");
        int a = sc.nextInt();
        switch(a){
            case 1:
                System.out.println("dog");
                break;
            case 2:
                System.out.println("cat");
                break;
            case 3:
                System.out.println("chick");
                break;
            default:
                System.out.println("I don't know.");
        }
    }
}
728x90
반응형
LIST