---
# System prepended metadata

title: '002public class if-else結構式 {'

---


# 002public class if-else結構式 {
if (條件判斷) {敘述1;…}
else {敘述2;…} 
成績分級

```
public static void main(String[] args) {
   int Score = (int)(Math.random()*101); // 0 - 100
    System.out.println(Score);
    if (Score >= 90){
        System.out.println("A");
    }else if (Score >= 80){
        System.out.println("B");
    }else if (Score >= 70){
        System.out.println("C");
    }else if (Score >= 60){
        System.out.println("D");
    }else{
        System.out.println("E");
    }
}

}
```
