Guest User

Untitled

a guest
Mar 4th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. public class Solution
  2. {
  3. public static void main(String[] args)
  4. {
  5. closeToTen(8,11);
  6. closeToTen(14,7);
  7. }
  8.  
  9. public static void closeToTen(int a, int b)
  10. {
  11. int q = 10 - a;
  12. int w = 10 - b;
  13. if (abs(q) > abs(w))
  14. System.out.println(w);
  15. else
  16. System.out.println(q);
  17.  
  18.  
  19. }
  20.  
  21. public static int abs(int a)
  22. {
  23. if (a < 0) {
  24. return -a;
  25. } else {
  26. return a;
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment