Computer Science, asked by mraggressive2005, 1 year ago

Wapto check whether a number is spy number or not
in blue j

Answers

Answered by Paulian42
1

import java.io.*;

class Spy

{

   public static void main(String args[])throws IOException

   {

       InputStreamReader in = new InputStreamReader(System.in);

       BufferedReader br = new BufferedReader(in);

       System.out.print("Enter the number: ");

       int n = Integer.parseInt(br.readLine());

       int sum = 0;

       int product = 1;

       for(int i = n; i != 0; i /= 10)

       {

           int digit = i % 10;

           sum += digit;

           product *= digit;

       }

       if(sum == product)

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

       else

           System.out.println("Not spy number.");

   }

}

Similar questions