Computer Science, asked by Powerman123, 1 year ago

write a Java Program to check whether the given numbers is a duck number or not.
(a number is said to be duck number if it has zero in it)

The output should be
Question: Enter the number
Number entered by us: 20124

Answer by the computer should be:
it is a duck number

Answers

Answered by prathamesh1855
3
Here's a android java
package com.my.newproject6;

import android.app

import android. os.*

import android.view.

import android view View.

import android.widget.*;

mport android content

import android.content.ClipboardManager

import android graphics.*;

import android.media.

import android.net.

import android. text.

import android.uti

import android.webkit.*,

import android. animation.

import android.view animation

import Java-utl

import java text.

public class MainActivity extends Activity

private HorizontalScrollView hscroll1,

private LinearLayout near

private Edit Text edittext1,

private Button button1;

Note that there are two enters it needs Only one enter
And it's a android therefore change toast to Println
Attachments:

Powerman123: sorry but i need for computer based
Powerman123: hi
Answered by siddhartharao77
6
public static void main(String[] args)
{
Scanner demo = new Scanner(System.in);

System.out.println("Enter a number");

int number = demo.nextInt();

int a = 0;

int b;

while(number!=0)

{

b = number%10;

if(b == 0)

a++;

number=number/10;

}

if(a > 0)

{

System.out.println("The number is a duck number");

}

else

{

System.out.println("The number is not a duck number");

}

}



Hope this helps!
Similar questions
Math, 1 year ago