Search
 
SCRIPT & CODE EXAMPLE
 

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();
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: -Xlint:deprecation 
Java :: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade java.lang.OutOfMemoryError (no error message) 
Java :: how to clear stringbuilder in java 
Java :: simple yes no dialog android default java 
Java :: add days to date java 
Java :: java declare multilayred array values 
Java :: prime check jaba 
Java :: Which package contains the Java Collections Framework? Group of answer choices java.net 
Java :: string array to stream 
Java :: How to efficiently count the number of smaller elements to the right of every array element, in Java? 
Java :: Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x); 
Java :: java new string array 
Java :: sort array<entry float android studio 
Java :: spring config.xml file 
Java :: toString convert to long 
Java :: lombok get error in extended classes¨ 
Java :: count the number of words in a string java 
Java :: HOW TO SUPRESS sonar warning in java code 
Java :: afficher texte java 
Java :: difference between offer and add in linkedlist in java 
Java :: 2 power 8 in java 
Java :: how to make an arraylist java 
Java :: java button actionlistener 
Java :: java connect mariadb 
Java :: assert system.out.println 
Java :: java jframe button 
Java :: status codes springboot 
Java :: java swing timer sleep 
Java :: greatest common divisor java 
Java :: create jframe java 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =