In: Computer Science
Program:
import java.util.*;
public class Multiple
{
//static method to check
public static boolean printIsMultiple(int no1,int no2)
{
//default boolean value of b
boolean b=false;
//condition to check whether the second is multiple of the
first
if(no1%no2==0)
{
b=true;
}
//return the value either true or false
return b;
}
public static void main(String[] args)
{
int no1,no2;
Scanner sc=new Scanner(System.in);
//accepting values from user using scanner
System.out.print("\nEnter the first integer: ");
no1=sc.nextInt();
System.out.print("\nEnter the second integer: ");
no2=sc.nextInt();
//calling the printIsMultiple() method
boolean b=printIsMultiple(no1,no2);
System.out.println("\n-----------------------------------------------
\n");
if(b==true)
{
System.out.println(b+": the second is the multiple of the
first!");
}
else
{
System.out.println(b+": the second is not the multiple of the
first!");
}
System.out.print("\n");
}
}
Output: