본문 바로가기

프로그래밍 문제/정올

545 : 반복제어문2 - 자가진단5

Java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = 0;
        int count_three = 0, count_five = 0;
 
        for (int i=0; i<10; i++) {
            num = sc.nextInt();
            if ((num%3== 0)
                count_three++;
            if ((num%5== 0)
                count_five++;
        }
 
        System.out.println("Multiples of 3 : " + count_three);
        System.out.println("Multiples of 5 : " + count_five);
    }
}
cs