Practice 5. Selection - khu.ac.krcvlab.khu.ac.kr/practice05.pdf · Practice 5. Selection 5 Enter...
Transcript of Practice 5. Selection - khu.ac.krcvlab.khu.ac.kr/practice05.pdf · Practice 5. Selection 5 Enter...
Practice 5. Selection
2
Practice 5. Selection
3
Enter three integers: 3 10 20 The smallest: 3 The largest: 20 Is there a number less than 20?: Yes Are all numbers in range (10~90)?: No
Practice 5. Selection
4
Enter three scores (0~100): 90 80 70 The grade is B
Practice 5. Selection
5
Enter three constants: 1 -6 9 There is only one real root.
Enter three constants: 1 3 1 There are two real roots.
Enter three constants: 1 1 3 There are no real roots.
Practice 5. Selection
6
• Multiple “if” statements in this program can be effectively converted to a “switch-case” statement.
• Convert it.
Execution examples
Enter month number: 6 It is June.
Enter month number: 5 It is May.
Practice 5. Selection
7
Enter two integers: 1 4 Choose operation: + Result: 5
Enter two integers: 4 10 Choose operation: / Result: 0.4