-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq3.java
More file actions
29 lines (29 loc) · 867 Bytes
/
q3.java
File metadata and controls
29 lines (29 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*Given two non-negative int values, return true if they have the same last digit, such
as with 27 and 57. Note that the % "mod" operator computes remainders, so 17 %
10 is 7.
lastDigit(7, 17) → true
lastDigit(6, 17) → false
lastDigit(3, 113) → true */
//Id - 21CE002 Andrew
import java.util.*;
public class q3 {
static boolean lastDigit(int a,int b){
if(a%10 == 0 && b% 10 == 0)
{
return true;
}
else if(b % 10 ==a || a % 10 == b || a ==b ){
return true;
}
else
return false ;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter 1st no");
int a = sc.nextInt();
System.out.println("Enter 2nd no");
int b = sc.nextInt();
System.out.println(lastDigit(a,b));
}
}