package edu.exam01.switch_case17;
//switch case로 범위 설정
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("숫자를입력하세요 :");
int num = sc.nextInt();
while (num < 0 || num > 100) {
System.out.println("다시 입력하세요.");
num = sc.nextInt();
}
num=(int)num/10; //캐스팅
switch (num) {
case 10:
System.out.println("A학점");
break;
case 9:
System.out.println("A학점");
break;
case 8:
System.out.println("B학점");
break;
case 7:
System.out.println("C학점");
break;
case 6:
System.out.println("D학점");
break;
default:
System.out.println("F학점");
break;
}
}
}
200107_switch_case 범위 설정 예제
2020. 1. 7. 16:48