자바_기초

제어문 - 조건문 if

잠수콩 2019. 5. 14. 08:40
//	package 생성
package ControlFlow;
//	제어문 - 조건문, 반복문

public class If_Ex {
	// 조건문 - if
	
	public static void main(String[] args) {				
		// 나이가 20 이상이면 성인입니다.
		
		// 비교형
		int age = 25;
		
		if(age >= 20) {
			System.out.println("성인입니다.");
		} else {
			System.out.println("미성인입니다.");
		}
		
		// boolean 형
		boolean res = age >= 20;
		System.out.println("res=" + res);	
		
		if(res) {
			System.out.println("성인입니다.");		
		} else {
			System.out.println("미성인입니다.");
		}
		
		// 성적
		int score = 100;
		if(score >= 90) {
			System.out.println("A학점!");
		}
		if(score >= 80) {
			System.out.println("B학점!");
		}
		if(score >= 70) {
			System.out.println("C학점!");
		}
		// A, B, C 다 나옴

	}

}