Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please do it like what the sample run shows (java) Write a method isMultiple tha

ID: 3806647 • Letter: P

Question

Please do it like what the sample run shows

(java) Write a method isMultiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The method should take two integer arguments and return true if the second is a multiple of the first and false otherwise. [Hint: Use the remainder operator.] Incorporate this method into an application that inputs a series of pairs of integers (one pair at a time) and determines whether the second value in each pair is a multiple of the first.har()

Sample run:

Enter one number: 7

Enter a second number: 49

49 is a multiple of 7

Do you want to enter another pair(y/n)? y

Enter one number: 2

Enter a scond number: 6

6 is a multiple of 2

Do you want to enter another pair(y/n)? y

Enter one number: 56

Enter a second number: 9

9 is not a multiple of 56

Do you want to enter another pair(y/n)? n

Explanation / Answer

import java.util.Scanner;

public class checkMultiple {

   public static boolean isMultiple(int m,int n)

   {  

       if(m%n==0)

       {

           return true;

       }

       return false;

   }

   public static void main(String[] args)

   {

       Scanner scan = new Scanner(System.in);

       int n,m;

       String ch;

       while(true)

       {

           System.out.print("Enter one number:");

           n = scan.nextInt();

          

           System.out.print("Enter a second number:");

           m = scan.nextInt();

          

           if(isMultiple(m, n))

           {

               System.out.println(m+" is a multiple of "+n);

           }

           else

           {

               System.out.println(m+" is not a multiple of "+n);

           }

           System.out.print("Do you want to enter another pair(y/n)?");

           ch = scan.next();

           //System.out.println(ch);

           if(ch.equals("y"))

           {

               continue;

           }

           else

           {

               break;

           }

       }

   }

}