Language_Coder 128 : 반복제어문1 - 형성평가4

boom.jun.cho·2022년 3월 14일
0

Language_Coder_JUNGOL

목록 보기
79/197

문제

0 이 입력될 때까지 정수를 계속 입력받아 3의 배수와 5의 배수를 제외한 수들의 개수를 출력하는 프로그램을 작성하시오.

입력

1 2 3 4 5 6 7 8 9 10 0

출력

5

코드

package com.jungol.algorithm079;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int count = 0;
    	
    	while(true) {
    		int number = scanner.nextInt();
    		
    		if(number % 3 != 0 && number % 5 !=0) {
    			count++;
    		}else if(number == 0) {
    			break;
    		}
    	}
    	System.out.print(count);
    	
    	scanner.close();
    }
}

    		
    		
profile
하루하루 최선을

0개의 댓글