# Answer to Question #3529 in Java | JSP | JSF for Y mukundareddy

Question #3529

Test if a number is a multiple of 3, 5 or 7.

Expert's answer

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

int n;

Scanner in = new Scanner(System.in);

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

n = in.nextInt();

if(n % 3 == 0)

System.out.println(n + " is a multiple of 3");

if(n % 5 == 0)

System.out.println(n + " is a multiple of 5");

if(n % 7 == 0)

System.out.println(n + " is a multiple of 7");

if((n % 3 != 0)&&(n % 5 != 0)&&(n % 7 != 0))

System.out.println(n + " is a not multiple of 3, 5 or 7");

}

}

public class Main {

public static void main(String[] args) {

int n;

Scanner in = new Scanner(System.in);

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

n = in.nextInt();

if(n % 3 == 0)

System.out.println(n + " is a multiple of 3");

if(n % 5 == 0)

System.out.println(n + " is a multiple of 5");

if(n % 7 == 0)

System.out.println(n + " is a multiple of 7");

if((n % 3 != 0)&&(n % 5 != 0)&&(n % 7 != 0))

System.out.println(n + " is a not multiple of 3, 5 or 7");

}

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment