Computer Science, asked by latajaiswal407, 9 months ago

Wap to input and check if it is a duck no. Or not

Answers

Answered by adityadhall007
1

Answer:

WHAT ARE YOU SAYING I CAN'T UNDERSTAND PLS TELL CLEARLY

Answered by varshithrs432
2

Explanation:

import java.util.Scanner;

public class Ducknumber {

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Input a number : ");

String nstr = sc.nextLine();

int l = nstr.length();

int ctr = 0;

char chr;

for(int i=1;i<l;i++)

{

chr = nstr.charAt(i);

if(chr=='0')

ctr++;

}

char f = nstr.charAt(0);

if(ctr>0 && f!='0')

System.out.println("Duck number");

else

System.out.println("Not a duck number");

}

}

Hope it helps you..

Mark my answer as brainlist

Vote me a thanks..

And follow me bros....

Similar questions