ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [baekjoon] 9498번: 시험 성적
    study Log/baekjoon 2022. 12. 29. 23:21

    제출
    import java.util.Scanner;
    
    public class number_9498 {
    
    	public static void main(String[] args) {
    		
            // 하드 아니고 더티 코딩
    		Scanner sc = new Scanner(System.in);
    		
    		int score = sc.nextInt();
    		
            // 이건 굳이 범위 설정을 해 준 코드...
            // 더 쉬운 방법이 있었을 테지만 맥북 자바 설정하느라 힘들어서 ㅠㅠ
            // 100 이상을 입력하면 F가 뜨길래 범위 설정 해 준거고 안해줘도 됨!
            // 밑에 코드블럭 대로 해도 충분
    		if (score >= 90 && score <= 100) {
    			System.out.println("A");
    		} else if (score >= 80 && score <= 89) {
    			System.out.println("B");
    		} else if (score >= 70 && score <= 79) {
    			System.out.println("C");
    		} else if (score >= 60 && score <=69) {
    			System.out.println("D");
    		} else if (score >= 0 && score <= 100) {
    			System.out.println("F");
    		}
    	}
    }
    import java.util.Scanner;
    
    public class number_9498 {
    
    	public static void main(String[] args) {
    		
    		Scanner sc = new Scanner(System.in);
    		
            // 스캐너로 정수 입력 받기
    		int score = sc.nextInt();
    		
            // 사실 범위 설정 안해줘도 이 문제는 알아서 100 이하로 입력 받기 때문에 상관없다.
    		if (score >= 90) {
    			System.out.println("A");
    		} else if (score >= 80) {
    			System.out.println("B");
    		} else if (score >= 70) {
    			System.out.println("C");
    		} else if (score >= 60) {
    			System.out.println("D");
    		} else (score >= 0) {
    			System.out.println("F");
    		}
    	}
    }
    결과

    정수 범위설정 안 해주고 올린 코딩 결과ㅏㅏㅏㅏㅏ!

    'study Log > baekjoon' 카테고리의 다른 글

    [baekjoon] 14681번: 사분면 고르기  (0) 2022.12.29
    [baekjoon] 2753번: 윤년  (0) 2022.12.29
    [baekjoon] 1330번: 두 수 비교하기  (0) 2022.12.29
    [baekjoon] 10869번: 사칙연산  (0) 2022.12.27
    [baekjoon] 1008번: A/B  (0) 2022.12.27

    댓글

Designed by Tistory.