WAP to check and print wheatherbentered the number is excatly divisible by 6 or not.
Answers
Answer:
import java.util.*;
class a
{
public static void main(String args[])
{
Scanner on=new Scanner(System.in);
int n=on.nextInt();
if(n%6==0)
System.out.println("it is divisible");
else
System.out.print("it is not divisible");
}
}
choice = "Yes"
while choice == "Yes":
n = int(input("Enter a number: "))
print()
if n%6 == 0:
print("The number is exactly divisible by 6.")
elif n%6 != 0:
print("The number is not exactly divisble by 6.")
print()
choice = input("Would you like to go again? [Yes/No]: ")
print()
For checking if a number entered is divisible, the remainder will have to be equivalent to 0. To check that, the modulus operation (%) is used. When a modulus operation takes place, the program only prints the remainder.