Write a program in Java to accept a number (using Function argument of main ( )
method) and check that it is 4 digits Magic Number or not. (Use Complex if
Statement only to perform the task, looping statement is not allowed) Display
the results with proper message. [Magic Number Example: 1027, 1000, 9991 etc.
Hint: In this type of number if it is divided by 9 then remainder is always 1.]
Answers
Answered by
2
Answer:
class MagicNumber
{
public void main(int a)
{
if((a%9) == 1)
{
System.out.println ("Magic Number");
}
else
{
System.out.println("Not Magic Number");
}
}
}
I hope you find it useful... If you have any query do comment, I will try to solve it...
Similar questions
Math,
4 months ago
Geography,
4 months ago
Math,
4 months ago
Accountancy,
9 months ago
Social Sciences,
9 months ago
Hindi,
1 year ago
English,
1 year ago