Friday, June 3, 2016

Java Challenge - make10 - warm_up

Given 2 ints, a and b, return true if one if them is 10 or if their sum is 10.

makes10(9, 10) → true
makes10(9, 9) → false
makes10(1, 9) → true

Hisoka's answer :
1
2
3
public boolean makes10(int a, int b) {
  return(a == 10 || b==10 || a+b==10);
}

Hasilnya :

Codingbat style:
1
2
3
public boolean makes10(int a, int b) {
  return (a == 10 || b == 10 || a+b == 10);
}

Waaaw... samaaa... :D

No comments:

Post a Comment