Computer Science, asked by Anonymous, 1 year ago

WAP to check whether a number is duck number or not !

DO IN JAVA PLEASE

SHOW THE OUTPUT PLEASE

Answers

Answered by Anonymous
35

\textsf{\huge{\underline{\underline{CODE}}}}


import java.util.*;

class duck_number

{

public static void main(String args[ ])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter a number to check whether it is a duck number or not");

int n=sc.nextInt();

int cpy=n;

int d=0;

int f=0;

while(n>0)

{

d=n%10;

if(d==0)

{

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

f++;

break;

}

n=n/10;

}

if(f==0)

{

System.out.println(cpy+" is not a duck numer");

}

}

}

----------------------------------------------------------------------------------------

OUTPUT [ In attachment ]

duck_num1.main();

Enter a number to check whether it is a duck number or not

9087

9087 is a duck number

----------------------------------------------------------------------------------

NOTE :

⇒ A duck number is a number which has at least 1 zero in its digit .

⇒ For example : 6041 is a duck number .

⇒ Example : 641 is not a duck number

⇒ Use copy variable only if you want to print the output along with the original input !

⇒ Otherwise you may not use the copy variable .

⇒ Use static void main if you are using a back dated compiler otherwise only void main() may work !

----------------------------------------------------------------------------------------------

Hope it helps bro !

__________________________________________________________________

Attachments:

Anonymous: BRILLIANT bro magnificent !!!! thank u soo much !!!
Anonymous: welcome:-)
Answered by samarpitalds
24

Answer:

Here's your answer

Explanation:

Please mark as Brainliest

Attachments:
Similar questions