Spy number - Java program simple for spy number
A spy number is a numbe where the sum of its digits equals the product of its digits.Thus There the need of a module operant comes in theprogram.
This a complied and working program as per the guidlines of icse .
Well if you have doubts please feel free asking in the comments section below .
import java.util.*;
public class spy
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int n,sum=0,p=1,d;
System.out.println("Enter the number");
n=in.nextInt();
while(n>0)
{
d=n%10;
sum=sum+d;p=p*d;
n=n/10;
}
if(sum==p)
System.out.println("true");
else
System.out.println("false");
}
}
This a complied and working program as per the guidlines of icse .
Well if you have doubts please feel free asking in the comments section below .
import java.util.*;
public class spy
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int n,sum=0,p=1,d;
System.out.println("Enter the number");
n=in.nextInt();
while(n>0)
{
d=n%10;
sum=sum+d;p=p*d;
n=n/10;
}
if(sum==p)
System.out.println("true");
else
System.out.println("false");
}
}
Comments
Post a Comment