출처: https://bumcrush.tistory.com/182 [맑음때때로 여름]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
        /* 
    
         - 제어문
             
             조건문
                 if
                 else
                if - else if - else
                switch
                 
             순환문
                 for
                 foreach (for문을 간단하게 만든 것)
                 while
                 do while
                 /break
                 /continue
             
         */
        
                    
            
    //    if ( 조건(true) ) { 처리  }
        // if 예제1)
        
        int number=5;
        
        if (number>0) { //참 
            System.out.println("number는 0보다 큽니다"); // 출력
        }
        if (number>5) { //거짓
            System.out.println("number는 5보다 큽니다"); //출력되지않음
        }
        
        // if 예제2)
        
        boolean b=true;
        if(b==true) {
            System.out.println("B는 TRUE입니다");
        if(b!=false)
            System.out.println("B는 TRUE입니다");
        }
        
        
        
    /* if(조건1=true){실행}
         else{실행}                  // 조건1이 false일 경우
     */
        
        
        
        // if-else 예제1
        
        number=10;
        if(number>5) {
            System.out.println("넘버는 5보다 크다");} // 출력O
        else {
            System.out.println("넘버는 5보다 작다");} // 출력X
        
            
    /* 조건분기 n개의 조건
         if
         else if
         else if * n개
         else
     
     */
    
        
        // else if 예제1
    
        number = 85 ;
        
        if(number==100) {
            System.out.println("A");}
            else if (number >=80 ) {
            System.out.println("B");}
            else if (number >=70 ) {             // B 출력
            System.out.println("C");}
            else
            {System.out.println("D");}
            
    
    
        // 조건문 안에 조건문
    
        number=95;
        
        if(number>=90) {
            if(number>=95) {
                System.out.println("A++");
            }
            else {System.out.println("A");}
        }
        else if (number>=80) {
            
        }
        
    
    
 
cs

+ Recent posts