Write a Java Program to Check Spy Number In Java

A program in java to accept a number and check whether it is a spy number in java or not.

Code to check spy number in java:-

Example –

import java.util.Scanner;

class Spy{

    public static void main(){

        Scanner sc = new Scanner(System.in);

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

        int n = sc.nextInt();

        int s=0, p=1;

        while(n>0){

            s += n%10;

            p *= n%10;

            n /= 10;

        }

        if(s==p)

        System.out.println(“It is a Spy number.”);

        else

        System.out.println(“It is not a Spy number.”);

    }

}

Thanks, you can comment me If you need to know more

The 5 Essential Tips For Living A Happy Life – For Students

দাবা খেলার নিয়ম : 6টি অনলাইন দাবা খেলার ওয়েবসাইট বিনামূল্যে

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x