본문 바로가기
study/Java

[Java] 6 ~10. TEST3 풀이 (점수를 입력 받아서 학점 출력하기)

by 금이패런츠 2022. 3. 11.
728x90
반응형
package chap3;

import java.util.Scanner;

/*
 * 화면에서 점수를 입력받아서 
 * 90점 이상이면 A학점,80점 이상이면 B학점 ... 60 점 미만이면 F학점을 출력하기
 */
 
public class Test0303_3 {
	public static void main(String[] args) {
    
        //풀이
		System.out.println("점수를 입력하세요");
		Scanner scan = new Scanner(System.in);
		int score = scan.nextInt();
		String result = (score >= 90)?"A":
			            (score >= 80)?"B":
			            (score >= 70)?"C":
			            (score >= 60)?"D":"F";
			            
		System.out.println(score + ":" + result + "학점");
	}
}
728x90
반응형