Post-Test Loop : do-while // 한번은 무조건 반복한다.
import java.util.Scanner;
public class Test001 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int month;
do {
System.out.print("올바른 월 입력: ");
month = sc.nextInt();
} while (month < 1 || month > 12);
System.out.println(month);
}
}
댓글 없음:
댓글 쓰기