JAVA - 3,6,9게임의 3,6,9,의 박수의 개수 구하는 퀴즈
2022. 7. 17. 00:08ㆍ3층 1구역 - 개발의 장/JAVA
package loop_while;
import java.util.Scanner;
public class Quiz03 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("369게임의 3,6,9의 박수의 개수 구하기");
/*System.out.print("수 입력 : ");
int num = sc.nextInt();
int count = 0;
for(int i = 1; i <= num; i++) {
int current = i;
int temp = count;
while(current != 0) {
if(current % 10 == 3 || current % 10 == 6 || current % 10 == 9) {
count ++;
}
current /= 10;
}
}
System.out.println("출력 : " + count);*/
System.out.print("입력 : ");
int end = sc.nextInt();
int count = 0;
for(int i =3; i <= end; i++) {
int data = i;
while(true) {
int tmp = data % 10;
if(tmp == 3 || tmp == 6 || tmp == 9) {
count++;
System.out.println("카운팅 : " + i);
}
data/=10;
if(data == 0)
break;
}
}
System.out.println("1 ~ " + end + "는(은)" + count + "번");
}
}
'3층 1구역 - 개발의 장 > JAVA' 카테고리의 다른 글
JAVA - 동전 앞, 뒷면 맞추는 퀴즈 (0) | 2022.07.17 |
---|---|
JAVA - 회원가입하고 로그인하는 퀴즈 (0) | 2022.07.17 |
JAVA - 규칙이 있는 수의 합이 100이 넘는 마지막 수 2개를 구하는 퀴즈(2022-07-16) (0) | 2022.07.17 |
JAVA - 쥐가 번식하고, 쌀창고 거덜내는 퀴즈(2022-07-16) (0) | 2022.07.16 |
JAVA - 입력된 수의 각 자리수의 합을 구하는 퀴즈 (2022-07-16) (0) | 2022.07.16 |