Code is copied!
Define a class to accept a 3 digit number and check whether it is a duck number or not.
Note: A number is a duck number if it has zero in it
Example1:
Input: 2083
Output: Invalid
Example 2:
Input: 103
Output: Duck number
Solution:
,
import java.util.*;
class duck
{
public static void main(String args[])
{
int num;boolean check=false;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
num = sc.nextInt();
while(num!=0)
{
int d=num%10;
if(d==0)
check=true;
num/=10;
}
if(check)
System.out.println("Duck Number");
else
System.out.println("Not Duck Number");
}
}