본문 바로가기

프로그래밍/자바

[자바] 정올 633 : 반복제어문1 - 자가진단6

728x90
반응형
SMALL
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i;
        boolean a = true;
        while(a){

            System.out.print("1. Korea\n" +
                    "2. USA\n" +
                    "3. Japan\n" +
                    "4. China\n" +
                    "number? ");
            i = sc.nextInt();
            switch(i){
                case  1:
                    System.out.println("\nSeoul");
                    break;
                case 2:
                    System.out.println("\nWashington");
                    break;
                case 3:
                    System.out.println("\nTokyo");
                    break;
                case 4:
                    System.out.println("\nBeijing");
                    break;
                default:
                    System.out.println("\nnone");
                    a = false;
            }//end switch

        }
    }
}
728x90
반응형
LIST