Skip to content
import java.util.*;
public class spy_number
{
   public static void main(String args[])
   {
     Scanner sc=new Scanner(System.in);
     System.out.println("***To check Spy number please enter 3 digits***");
     System.out.println("Enter your first digit");
     int dig1=sc.nextInt();
     System.out.println("Enter your second digit");
     int dig2=sc.nextInt();
     System.out.println("Enter your third digit");
     int dig3=sc.nextInt();
     System.out.println("Enter your fourth digit");
     int dig4=sc.nextInt();
     int sum=dig1+dig2+dig3+dig4;
     int product=dig1*dig2*dig3*dig4;
     if(sum==product)
     {
         System.out.println("\f");
         System.out.println("Digits entered are"+ dig1 + dig2 + dig3 + dig4);
         System.out.println("Sum of your digits is"+sum);
         System.out.println("Product of your digits is"+product);
         System.out.println("Both the sum and product is equal so, It is a spy number");
        }
        else
        {
         System.out.println("\f");
         System.out.println(" Digits entered are"+ dig1 + dig2 + dig3 + dig4);
         System.out.println("Sum of your digits is"+sum);
         System.out.println("Product of your digits is"+product);
         System.out.println("Both the sum and product is not equal so, It is not a spy number");
        }
    }
}

 

Submitted By: Ms. Zarin Shroff

If this program was helpful to you, do leave a comment.
All Creadit goes to Ms. Zarin Shroff

P.N. : All the post on this website are for demonstration and education purpose only.
Student should perform all the practicals for there personal copies.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!