Как -1 должен учитываться? Он у меня выполняет свою функцию.
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader num = new BufferedReader(new InputStreamReader(System.in));
while (true) {
int a = Integer.parseInt(num.readLine());
int b = Integer.parseInt(num.readLine());
int c = Integer.parseInt(num.readLine());
int d = Integer.parseInt(num.readLine());
int e = Integer.parseInt(num.readLine());
System.out.print(a + b + c + d + e);
if (a == -1 || b == -1 || c == -1 || d == -1 || e == -1)
break;
}
}
}
Так же уже фигней маялся, не понимая что от меня хотят.
if (a == -1 || b == -1 || c == -1 || d == -1 || e == -1) {
System.out.print(a + b + c + d + e + 2);
break;
} else {
System.out.print(a + b + c + d + e);
}
PS - Искал в гугле, как получать сумму, игнорируя знак перед числом (-), но ничего не нашел.