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
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
Computer Science,
2 months ago
Social Sciences,
2 months ago
English,
2 months ago
English,
5 months ago
Sociology,
10 months ago
Science,
10 months ago