write a program to enter a integer number and check whether the number is duck or not.A number is said to be duckif the digit zero is present in the number. example sample input:5063
sample output:it is a duck number.
sample input:5459
sample output:it is not a duck number... .give the answer by using scanner
Answers
Answered by
25
import java.util.*;
class Duck
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in)
System.out.println("Enter any number");
int n=sc.nextInt()
boolean found=false;
while(n!=0)
{
int d=n%10;
if(d==0)
{
System.out.println("Duck number");
found=true;
break;
}
}
if(found==false)
{
System.out.println("Not a duck number");
}
}
}
gyanendra5050501:
Great
Answered by
1
The above following programme is correct !
Similar questions