day04_FlowEx5

육희영·2021년 9월 2일
0

점수별 학점

package day04;

import java.util.Scanner;

public class FlowEx5 {

	public static void main(String[] args) {
		int score = 0;
		char grade = ' ', opt = ' ';

		System.out.print("점수를 입력하세요.>");
		Scanner scanner = new Scanner(System.in);
		score = scanner.nextInt();
		scanner.close();

		if (score >= 90) {
			grade = 'A';
			if (score >= 98) {
				opt = '+';
			} else if (score < 94) {
				opt = '-';
			}

		} else if (score >= 80) {
			grade = 'B';
			if (score >= 88) {
				opt = '+';
			} else if (score < 84) {
				opt = '-';
			}

		} else if (score >= 70) {
			grade = 'C';
			if (score >= 78) {
				opt = '+';
			} else if (score < 74) {
				opt = '-';
			}

		} else {
			grade = 'D';
		}
		System.out.printf("당신의 학점은 %c%c 입니다.%n", grade, opt);
	} // main End
} // class End

출력결과


이런식으로 설정한 점수에 따라 A,B,C,D 학점이 나온다

0개의 댓글

관련 채용 정보