Scanner sc = new Scanner(System.in);
System.out.println("1부터 99중에서 하나의 수를 입력해주세요");
int num = sc.nextInt();
int tenth = num / 10;
int first = num - (tenth * 10);
/*num 6 13 69
tenth 0 1 6
ㄴ0.6 / 1.3 / 6.9 이지만 실수만 표시
first 6 3 9
*/
if (num < 10) {
if (first % 3 == 0)//나누기 3했을떄 남는 수가 0과 같다
System.out.println("박수짝");
}
else if (num > 10) {
if (tenth % 3 == 0) {
if (first % 3 != 0)
System.out.println("박수짝");
if (first % 3 == 0)
System.out.println("박수짝짝");
}
else if (first % 3 == 0)
System.out.println("박수짝");
}
sc.close();
'java > java exercise' 카테고리의 다른 글
Calculate and display Student Grades (0) | 2020.01.25 |
---|---|
Print multiplication table (0) | 2020.01.25 |
Dice Game (0) | 2020.01.25 |
Changing Letter case (0) | 2020.01.25 |
Count Number of Notes (0) | 2020.01.25 |