본문 바로가기
(Pre-class)

If and If else?

by coramdeo643 2025. 3. 31.

1. If statement is working if a condition is true and if not, it will be skipped

// it can be executed or not

2. If-else statement is working whether it is true or not

// it will be executed in any case

3. Else-if statement is for the new condition, not true or false, for something else

// so we can add many options and conditions

if (score >= 90) {
	System.out.println("Grade A");
} else if (score >= 80) {
	System.out.println("Grade B");
} else if (score >= 70) {
	System.out.println("Grade C");
} else if (score >= 60) {
	System.out.println("Grade D");
} else {
	System.out.println("Grade F");
} // end of if

'(Pre-class)' 카테고리의 다른 글

For Loop?  (0) 2025.04.01
Nested if statement?  (0) 2025.03.31
import java.util.Scanner?  (0) 2025.03.30
Logical operator?  (0) 2025.03.30
Relational Operator?  (0) 2025.03.29