2011-07-13T16:41:01-04:00
Test if a number is a multiple of 3, 5 or 7.
1
2012-03-06T10:51:07-0500
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"); } }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
Java JSP JSF
Comments