-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlastDigit
More file actions
22 lines (22 loc) · 721 Bytes
/
lastDigit
File metadata and controls
22 lines (22 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*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
*/
public class lastDigit {
public static void main(String[] args) {
boolean output=lastDigit(7,17);
System.out.println(output);
boolean output1=lastDigit(6,17);
System.out.println(output1);
boolean output2=lastDigit(3,113);
System.out.println(output2);
}
public static boolean lastDigit(int a, int b){
if((a%10)==(b%10))
return true;
else
return false;
}
}