import java.util.Scanner;
public class Game_369 {
public static void main(String[] args) {
int iInput,iMod;
Scanner oInDev; //객체 선언
System.out.print("1~999 사이의 정수를 입력하시오 :");
oInDev = new Scanner(System.in);
iInput = oInDev.nextInt();
if(iInput > 0 && iInput < 1000) {
System.out.print("박수 ");
iMod = iInput % 10;
if(iMod == 3 || iMod == 6 || iMod == 9) {
System.out.print("짝");
}
iInput = iInput / 10;
iMod = iInput % 10;
if(iMod == 3 || iMod == 6 || iMod == 9) {
System.out.print("짝");
}
iInput = iInput / 10;
iMod = iInput % 10;
if(iMod == 3 || iMod == 6 || iMod == 9) {
System.out.print("짝");
}
iInput = iInput / 10;
}
else {
System.out.println("1~999 사이의 범위에 맞지 않습니다.");
}
oInDev.close(); //이거 엄청 중요
}
}
고쳐야 할 점
0보다 작거나 같으면? / 99보다 크면? → 예외 처리까지
뒤에서 부터 처리 ←369에서 3부터 처리하면 안됨
조건문을 긍정적으로 처리(예외를 else로)
프로그램을 하면서 계속 확인
Flag로 박수 안찍을 때로 예외 처리 추가하기