Write the Java code of a program that takes an integer from the user, and prints the…
- User
Write the Java code of a program that takes an integer from the user, and prints the integer it is a multiple of either 2 or 5 but not both. If the number is a multiple of 2 and 5 both, then print "Multiple of 2 and 5 both". For all other numbers, the program prints "Not a multiple we want". For example, 2, 4, 5, 6, 8, 12, 14, 15, 16, 18, 22 … i.e. this includes multiples of 2 only and multiples of 5 only, NOT multiples of 2 and 5 both or other numbers. hint(1): we may use the modulus (%) operator for checking the divisibility hint(2): we can consider the number to be an integer
Sample Input Output 6 6 15 15 10 Multiple of 2 and 5 both 17 Not a multiple we want
- Assistant
Sure, I will provide the Java code for the described program. This program will read an integer from the user, determine if it meets the required criteria, and print the appropriate message.
Here's the Java code:
java