Computer Science, asked by Aqsakhan49, 5 months ago

Write a program to accept a number and check whether the number is divisible by 3 as well as 5. Otherwise,
decide:
(a) Is the number divisible by 3 and not by 5?
(b) Is the number divisible by 5 and not by 3?
(c) Is the number neither divisible by 3 nor by 5?
The program displays the message accordingly.​

Answers

Answered by Smodak1702
15

Answer:

class sad

{

public void main (int n )

{

if (n%3==0&&n%5==0)

{

System.out.print ("it is divisble by both 3&5");

}

else

{ if (n%3==0&&n%!=0)

System.out.print (" it is only divisible by 3");

if (n%5==0&&n%!=0)

System.out.print ("it is only divisible by 5");

}}}

Explanation:

Similar questions