Computer Science, asked by ananya4062, 9 months ago

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 amansarrafas24payxgs
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