todor_boichev

Untitled

Sep 11th, 2020
261
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.sql.Time;
  2. import java.util.Scanner;
  3.  
  4. public class PROBA {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         System.out.print("n = ");
  8.         int count = Integer.parseInt(scanner.nextLine());
  9.         System.out.println("Enter the numbers: ");
  10.  
  11.         int leftSum = 0;
  12.         int rightSum = 0;
  13.  
  14.         for (int i = 0; i < count; i++) {
  15.             int num = Integer.parseInt(scanner.nextLine());
  16.             leftSum = leftSum + num;
  17.         }
  18.         for (int i = 0; i < count ; i++) {
  19.             int num = Integer.parseInt(scanner.nextLine());
  20.             rightSum = rightSum + num;
  21.         }
  22.  
  23.         if (leftSum == rightSum){
  24.             System.out.println("Yes, sum = " + leftSum);
  25.         }else {
  26.             int difference = Math.abs(leftSum - rightSum);
  27.             System.out.println("No, diff = " + difference);
  28.         }
  29.  
  30.  
  31.     }
  32. }
  33.  
RAW Paste Data