Computer Science, asked by parthomsarwade, 1 year ago

Write a program in java to accept a number and check if it is a spy number.
A number is said to be spy if sum of digits is equal to the product of digits
Ex:123
1+2+3=6
1*2*3=6

fast
use scanner class​

Answers

Answered by jyotisikhadash2
2

//Spy_number

import java.util.*;

class spyno

{

public static void main(String args

[]);

{

Scanner sc= new Scanner(

System.in);

int n;

System.out.println("Enter a

number");

n=sc.nextInt();

int m=n,d,p=1,s=0;

while(m>0)

{

d=m%10;

s=s+d;

p=p*d;

m=m/10;

}

if(s==p)

System.out.println("Spy no");

else

System.out.println("Not spy

no");

}

}

Answered by gracy55
0

Answer:

Parameters used in First Java Program. Let's see what is the meaning of class, public, static, void, main, String[], System.out.println(). class keyword is used to declare a class in java. ... static is a keyword. If we declare any method as static, it is known as the static method.

Similar questions