Computer Science, asked by rosamystica1975, 4 months ago

write a menu driven program to check whether a number is a Spy number​

Answers

Answered by 1minutememes1208
3

import java.util.Scanner;

public class SpyNumOrNot

{

   public static void main(String args[])

   {

       

       Scanner in = new Scanner(System.in);

       

       System.out.print("Enter Number: ");

       int num = in.nextInt();

       

       int digit, sum = 0;

       int num1 = num;

       int prod = 1;

       

       while (num > 0)

       {

           digit = num % 10;

           

           sum += digit;

           prod *= digit;

           num /= 10;

       }

       

       if (sum == prod)

           System.out.println(num1 + " is Spy Number");

       else

           System.out.println(num1 + " is not Spy Number");

       

   }

}

Similar questions