๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜

[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 9498๋ฒˆ - ์‹œํ—˜ ์„ฑ์ 

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 1. 31.
๋ฐ˜์‘ํ˜•

2. if๋ฌธ - ์‹œํ—˜ ์„ฑ์ 

 

 

๋ฌธ์ œ) ์‹œํ—˜ ์ ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ 90 ~ 100์ ์€ A, 80 ~ 89์ ์€ B, 70 ~ 79์ ์€ C, 60 ~ 69์ ์€ D, ๋‚˜๋จธ์ง€ ์ ์ˆ˜๋Š” F๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ ์ถœ๋ ฅ
100 A

 

import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a;
		a = sc.nextInt();
		switch (a / 10) {
		case 10:
		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;
		}
	}
}

if๋ฌธ์ด๋ผ๊ณ  ํ•ด์„œ if๋ฌธ๋งŒ ์‚ฌ์šฉํ•˜๋ฉด ์•ˆ๋œ๋‹ค๋Š” ๊ฒƒ์„ ๊นจ๋‹ฌ์•˜๋‹ค.

case 10์„ ์„ค์ •ํ•ด์ฃผ๋Š” ๊ฒƒ๊ณผ ์ ์ˆ˜๋ฅผ / 10ํ•˜๋Š”๊ฒŒ ํฌ์ธํŠธ

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€