Not too sure on how to start this program off. I know I have to declare my variables first. Then what comes next?
Write a java program that finds if one number is
perfectly divisible by another. The program should call a
method with the signature:
boolean perfectDivChecker(int num1, int num2)
Let’s examine this logically:
Given two numbers, we’ll need to decide if the first number (designated by parameter
num1), is evenly divisible by the second number (designated by parameter
num2). In the
perfectDivChecker method body, we need to write code to return
false, depending upon if this condition is satisfied.
How do we determine if one number is evenly divisible by another, mathematically speaking?: If we divide one number by the other, what must the result be? The quotient must must not be a decimal. Or, alternatively stated, the remainder of the operation must be 0 (nothing left over after division).
So what code can we write to determine if
num1, when divided by
num2, has a remainder of 0?
Once you’ve determined that logic, you can simply return the resultant boolean.
If the issue is “how do I format a Java program”, then you might try reviewing previous exercises, or this tutorial.