Programming/Java
[Java] 제어문 (if, switch, for, while, continue, break)
조건문: if, switch --+ 눈이 6개인 주사위를 던져서 나오는 숫자에 따라 동작하는 코드를 짠다고 할 때 1. If int N = 6; int result = (int) (Math.random()*N) + 1; if (result == 1) { // do something } else if (result == 2) { // do something } else if (result == 3) { // do something } else if (result == 4) { // do something } else if (result == 5) { // do something } else { // do something } 2. Switch int N = 6; int result = (int) (Math..
2022. 7. 31. 17:52
최근댓글