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

1. Write a method multiple thatdetermines, for a pair of integers, whether the s

ID: 3618333 • Letter: 1

Question

1.      Write a method multiple thatdetermines, for a pair of integers, whether the secondinteger is a multiple of the first. The method should take twointeger arguments and return true if the second is a multiple ofthe first and false otherwise. [Hint: Use the remainderoperator.] Incorporate this method into an application that inputsa series of pairs of integers (one pair at a time) and determineswhether the second value in each pair is a multiple of thefirst.

this this is what i did please correct me if i'm wrong

import java.util.Scanner;

public class Main

{


   /**

   * @param args the command line arguments

   */

   public static void main(String[] args)

   {

   Scanner scan=new Scanner(System.in);

   int n1 = scan.nextInt();

   int n2=scan.nextInt();

   while (n1!=n2)

   {

     System.out.print("enter two numbers");

   double ans =multiple (n1, n2);

     System.out.printf("ans is %d", ans);

     n1=scan.nextInt();

   }

   }//end main

   public static double multiple(double num1, double num2)

   {

   double result;

   if (num1%num2)

   result= num1;

   else

   result= num2;

   return result;

   }//end multiple

  

}//end class





Explanation / Answer

please rate - thanks your post talks about true and false, so you need booleans. % only works with ints I kept as much of your code as I could import java.util.Scanner; public class MAIN {     /**      * @param args the command linearguments      */     public static void main(String[] args)     {         Scanner scan=new Scanner(System.in);           System.out.print("enter two numbers");         int n1 =scan.nextInt();         intn2=scan.nextInt();         while (n1!=n2)         {                                   boolean ans = multiple (n1, n2);            System.out.printf("ans is %b ", ans);               System.out.print("enter two numbers (thesame to exit the program)");            n1=scan.nextInt();            n2=scan.nextInt();         }       }//end main         public static booleanmultiple (int num1, int num2)         {            boolean result;            if (num1%num2==0)                result = true;            else                result = false;            return result;         }//end multiple      }//end class