Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

duck number in java

import java.util.*;
class duck
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter Number: ");
        String num = sc.next();
        int c = 0, d;
        int l = num.length();
        for(int i = 1; i < l; i++)
        {
            d = num.charAt(i);
            if(d == '0')
            {
                c++;
            }
        }
        int f = num.charAt(0);
        if(c > 0 && f != 0)
        {
            System.out.println("Duck Number.");
        }
        else
        {
            System.out.println("Not a Duck Number.");
        }
        sc.close();
    }
}
 
PREVIOUS NEXT
Tagged: #duck #number #java
ADD COMMENT
Topic
Name
4+2 =