본문 바로가기

자바(JAVA)/기본 문법

JAVA(자바) 배수인지 판별

JAVA(자바) 배수인지 판별

 

public class Main {

	public static void main(String[] args) throws Exception {
		
		System.out.println(chenckMultiple(100, 4));

	}
	
	public static boolean chenckMultiple(int target, int num) {

		boolean result = false;

		if (target % num == 0) {

			result = true;

		}

		return result;

	}
}

 

 

결과에 따라 true / false 반환