Advertisement
Guest User

1

a guest
Feb 25th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) throws Exception {
  5.  
  6. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  7.  
  8. int sum = 0;
  9.  
  10. while (true) {
  11. String num1 = reader.readLine();
  12. int num = Integer.parseInt(num1);
  13. sum = sum + num;
  14.  
  15. if (num == -1) {
  16. System.out.println(sum);
  17. break;
  18. }
  19.  
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement