Computer Science, asked by Aasma00, 6 months ago

WAP to check and print wheatherbentered the number is excatly divisible by 6 or not.

Answers

Answered by a321038
1

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");

}

}

Answered by Equestriadash
8

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.

Attachments:
Similar questions