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

6.16 (Multiples) Write a method isMultiple that determines, for a pair of intege

ID: 3782991 • Letter: 6

Question

6.16 (Multiples) 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()

Prompts:

Enter a second number:

Enter one number:

Sample Outputs :

Enter one number:Enter a second number:49 is a multiple of 7

Do you want to enter another pair(y/n)?Enter one number:Enter a second number:28 is a multiple of 7

Do you want to enter another pair(y/n)?Enter one number:Enter a second number:42 is a multiple of 7

Do you want to enter another pair(y/n)?Enter one number:Enter a second number:7 is not a multiple of 42

Do you want to enter another pair(y/n)?Enter one number:Enter a second number:25 is a multiple of -5

Do you want to enter another pair(y/n)?Enter one number:Enter a second number:12 is a multiple of -12

Do you want to enter another pair(y/n)?Enter one number:Enter a second number:9 is not a multiple of 56

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

Explanation / Answer

Hi FRiend, You have not mentioned about any programing language.

Please try to provide all details.

I have completed implementation in JAVA.

import java.util.Scanner;

public class Multiples {

   public static boolean isMultiple(int first, int second){

       if(second%first == 0)

           return true;

       else

           return false;

   }

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       while(true){

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

           int first = sc.nextInt();

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

           int second = sc.nextInt();

           if(isMultiple(first, second))

               System.out.println(second+" is multiple of "+first);

           else

               System.out.println(second+" is not multiple of "+first);

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

           char c = sc.next().charAt(0);

           if('y' != Character.toLowerCase(c))

               break;

       }

   }

}

/*

Sample run:

Enter one number: 7

Enter a second number: 28

28 is multiple of 7

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

Enter one number: 8

Enter a second number: 24

24 is multiple of 8

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

Enter one number: 4

Enter a second number: 2

2 is not multiple of 4

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

*/