Likes

JAVA Lab03_Ans2

Write a program to check if the first number is divisible by the second number or not.
In addition, display approprate message accordingtothe result...


ANSWER

public class DivisibleChecker {

public static void main(string [] args) {

int num1, num2;
num1 = 32;

num2 = 12;

if (num1 % num2 == 0) {
    System.out.println("The first number is divisible by the second number");
} else {
System.out.println("The first number is not divisible by the second number");
}
}
}

No comments: