Computer Science, asked by taniyaguptpkt, 17 days ago

Write a programin Javato input two numbers P, Q. Verify whether Q is a factor of P or not​

Answers

Answered by Anonymous
1

Answer:

import java.util.Scanner;

class Factor

{

public static void main(String[] args)

{

//Declaration

Scanner scnr = new Scanner(System.in);

int p, q;

//Prompt and accept 2 numbers from user

System.out.println("Enter the 1st number: ");

p = scnr.nextInt();

System.out.println("Enter the 2nd number: ");

q = scnr.nextInt();

//Display

if (p % q == 0)

{

      System.out.println(q + " is a factor of " + p);

}

else

{

       System.out.println(q + " is a factor of " + p);

}

}

}

Similar questions