Computer Science, asked by Vishrut911, 9 months ago

write a program to accept the number and check whether the number is divisible by 3 as well as 5. ​

Answers

Answered by rushikeshraut2442
1

Explanation:

=> import java.util.Scanner;

public class Check_Divisiblity

{

public static void main(String[] args)

{

int n;

Scanner s = new Scanner(System.in);

System.out.print("Enter any number:");

n = s.nextInt();

if(n % 5 == 0)

{

System.out.println(n+" is divisible by 5");

}

else

{

System.out.println(n+" is not divisible by 5");

}

}

}

=> Output-

$ javac Check_Divisiblity.java

$ java Check_Divisiblity

Enter any number:45

45 is divisible by 5

Enter any number:16

16 is not divisible by 5

Hope it will help you.

Answered by yuvrajverma97
0

Answer:

to chek any number is divisible by 3 we add all the numbers that we have to chek then divide the sum by 3 if it is divided then the number will divides from 3.

to check any number is divisible by 5 we look at the last digit of the number if 0 or 5 are the last digit then the given number will divisible by 5

THANKS

Similar questions