It states that its not summing together. I cannot find where its failing.
package com.codegym.task.task04.task0442;
/*
Adding
*/
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
int sum = 0;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Boolean show = false;
String temp = reader.readLine();
String _temp = "";
int tmp = 0;
if (temp.length() > 1 && temp.substring(0, 1).equals("-")) {
_temp = temp.substring(1);
} else
_temp = temp;
while (_temp.matches("[0-9]+")) {
tmp = Integer.parseInt(temp);
sum += tmp;
if (tmp == -1) {
System.out.println("-1");
show = true;
break;
}
temp = reader.readLine();
if (temp.length() > 1 && temp.substring(0, 1).equals("-")) {
_temp = temp.substring(1);
} else
_temp = temp;
}
if (show)
System.out.println(sum);
}
}