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



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *