A **duck number** is a positive integer that has one or more zeroes present in it. However, the number should not begin with zero.

For instance, 1205, 500, etc. are duck numbers.

Write a program in **Java** to accept a positive integer from the user, and check whether it is a duck number.

```
import java.io.*;
class Duck{
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Positive integer: ");
int num = Math.abs(Integer.parseInt(br.readLine()));
int count = 0;
for(int i = num; i > 0; i /= 10){
int digit = i % 10;
if(digit == 0)
count++;
}
if(count > 0)
System.out.println(num + " is a duck number.");
else
System.out.println(num + " is not a duck number.");
}
}
```

## 3 replies on “Duck Number in Java”

Sir,a program is given which states that :

Write a program to create a square matrix of size [m × m] of type integer.

The value of ‘m’ is entered by the user and ensure that m > 3 and m < 10.

For an invalid size, display a suitable error message.

Now allow the user to enter integers into this matrix.

Once the array is full with integers, display the elements that fall below the left diagonal.

Here is the program to display the elements below the left diagonal in a square matrix.

Sir,a program is given which states that:

WAP in Java to accept some nos to create m×m matrix.The value of ‘m’ is entered by the user and ensure that m > 2 and m < 10.Now display the elements below the left diagonal of that matrix.