Answer to Question #310854 in Java | JSP | JSF for Jay

Question #310854

A number is said to be evenly divisible by 9 if it is divisible by 9 and at the same time it is even. For example 18 is evenly divisible by 9 but 27 is not. A program is required that accepts an integer and checks whether it is evenly divisible by 9 or not and then prints an appropriate message.



1
Expert's answer
2022-03-13T11:22:27-0400


import java.util.*;


class App {


	public static void main(String[] args) {
		Scanner keyboard = new Scanner(System.in);
		System.out.print("Enter number:");
		int number = keyboard.nextInt();
		if (number % 9 == 0 && number % 2 == 0) {
			System.out.println(number + " is evenly divisible by 9");
		} else {
			System.out.println(number + " is NOT evenly divisible by 9");
		}


		keyboard.close();
	}
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS