Computer Science, asked by bhan61, 1 year ago

write a method Met that takes two integer parameters a and b both are double digit numbers .you have to print true if one or more common digits are there else false in java
ex:27 76
true
34 88
false
29 39
true


bhan61: for some test cases if is not satisfied
nitish8089: like give example
bhan61: it is inbuilt
nitish8089: i thought it will satisy for all
bhan61: okay
bhan61: once i will check again
nitish8089: ya u could check out..
bhan61: thank you
bhan61: for your response
nitish8089: ur welcome..

Answers

Answered by nitish8089
5

import java.util.*;

class Bhan{

public static void met(int a,int b){

 while(a>0){

  int x=a%10;

  int temp=b;

  do{

   int y=temp%10;

   if(x==y){

    System.out.println("true");

    System.exit(0);

   }

   else{

    temp/=10;

   }

  }while(temp>0);

  a/=10;

 }

 System.out.println("False");

}

public static void main(String[] args) {

 Scanner sc=new Scanner(System.in);

 System.out.println("Enter first two digit number");

 int a=sc.nextInt();

 System.out.println("Enter second two digit number");

 int b=sc.nextInt();

 Bhan.met(a,b);

}

}

Similar questions
Math, 7 months ago