borkins

Exam Jan-2016 - 07. Sums Step 3

May 11th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. /**
  2.  * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _07_SumsStep3
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         int n = Integer.parseInt(console.nextLine());
  14.        
  15.         int sum1 = 0, sum2 = 0, sum3 = 0;
  16.        
  17.         for (int i = 0; i < n;)
  18.         {
  19.             if (i++ < n) sum1 += Integer.parseInt(console.nextLine());
  20.             if (i++ < n) sum2 += Integer.parseInt(console.nextLine());
  21.             if (i++ < n) sum3 += Integer.parseInt(console.nextLine());
  22.         }
  23.    
  24.         System.out.printf("sum1 = %d%nsum2 = %d%nsum3 = %d%n", sum1, sum2, sum3);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment