Write a programin Javato input two numbers P, Q. Verify whether Q is a factor of P or not
Answers
Answered by
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
Social Sciences,
8 days ago
Math,
8 days ago
Math,
17 days ago
Accountancy,
8 months ago
Science,
8 months ago