Guest User

Untitled

a guest
Mar 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. package net.ukr.shyevhen;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class HomeWorkL2E3 {
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9. int num;
  10. int a;
  11. int b;
  12. int c;
  13. int d;
  14. int left;
  15. int right;
  16. System.out.print("Enter the number: ");
  17.  
  18. num = sc.nextInt();
  19. a = num / 1000;
  20. b = num % 1000 / 100;
  21. c = num % 100 / 10;
  22. d = num % 10;
  23. left = a + b;
  24. right = c + d;
  25. if (left > 9) {
  26. a = left / 10;
  27. b = left % 10;
  28. left = a + b;
  29. } else if (right > 9) {
  30. c = right / 10;
  31. d = right % 10;
  32. right = c + d;
  33. } else {
  34.  
  35. }
  36. if (left == right) {
  37. System.out.println("You won =)");
  38. } else {
  39. System.out.println("You lose =(");
  40. }
  41.  
  42. }
  43.  
  44. }
Add Comment
Please, Sign In to add comment