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
Answers
Answered by
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