82) Write a program to input a number and check whether it is Magic Number or not? ( 64 = 6+4 = 10 = 1+0 = 1)
import java.util.*;
public class Magic_num
{
public static void main(String args[ ])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter a number");
int a = sc.nextInt();
int s = 10;
while(s>9)
{
s=0;
while(a>0)
{
int d = a%10;
a = a/10;
s=s+d;
}
a=s;
}
if(s==1)
{
System.out.println("Entered number is a MAGIC Number");
}
else
{
System.out.println("Entered number is not a MAGIC Number");
}
}}