Computer Science, asked by SattuTattu, 8 months ago

A number is said to be Cuckoo if the digit nine (9) is present in it. Write a JAVA program to accept a number and check whether the number is Cuckoo or not.

Answers

Answered by anindyaadhikari13
4

\star\:\:\:\bf\large\underline\blue{Question:-}

  • A number is said to be a Cuckoo of the digit 9 is present in it. Write a java program to accept a number and check whether the number is cuckoo or not.

\star\:\:\:\bf\large\underline\blue{Source\:Code:-}

import java.util.*;

class IfCuckoo

{

public static void main(String s[ ])

{

Scanner sc = new Scanner(System.in);

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

int n=sc.nextInt();

boolean x=false;

while(n!=0)

{

int d=n%10;

if(d==9)

x=true;

n/=10;

}

if(x)

System.out.println("Given number is a Cuckoo Number.");

else

System.out.println("Given number is not a Cuckoo Number.");

} // end of main method.

} // end of class.

Answered by Vyomsingh
3

\huge\bf\blue{<u>QUESTION➠</u>}

Java Program to Check weather the given no.is CUCKOO number or not.

_______________________________

\large\bf\pink{what \: is \: cuckoo \: number - }

A number is said to be Cuckoo if the digit nine (9) is present in it.

Example:-

1269

1629

3749

98377

7893.....etc

__________________________________

\large\bf\purple{CODE➽}

  1. class Cuckoo
  2. {
  3. public static void main (int n)
  4. {
  5. int m=n;
  6. for(int k=0;m>0;m=m/10)
  7. {//open of Loop brace
  8. k=m%10;
  9. if(k==9)//Condition to check whether no.is cuckoo or not
  10. {
  11. System.out.println(n+" is Cuckoo Number");
  12. break;
  13. }
  14. } // close of Loop brace
  15. if(m==0)
  16. System.out.println(n +" is Not a Cuckoo Number");
  17. }
  18. }

_________________________________

Input:- 23469673

Output:- 23469673 is Cuckoo Number

Similar questions