Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.ukr.shyevhen;
- import java.util.Scanner;
- public class HomeWorkL2E3 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int num;
- int a;
- int b;
- int c;
- int d;
- int left;
- int right;
- System.out.print("Enter the number: ");
- num = sc.nextInt();
- a = num / 1000;
- b = num % 1000 / 100;
- c = num % 100 / 10;
- d = num % 10;
- left = a + b;
- right = c + d;
- if (left > 9) {
- a = left / 10;
- b = left % 10;
- left = a + b;
- } else if (right > 9) {
- c = right / 10;
- d = right % 10;
- right = c + d;
- } else {
- }
- if (left == right) {
- System.out.println("You won =)");
- } else {
- System.out.println("You lose =(");
- }
- }
- }
Add Comment
Please, Sign In to add comment