I cant get the new entered numbers to be added to the existing sum which obviously is 0 at the start.
Hope to get some help here. thanks guys.
public class Solution {
public static void main(String[] args) throws Exception {
//schreib hier deinen Code
int x = 0;
int y = 0;
while (true){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
int x = Integer.parseInt(s);
if (x == -1);
break;
else (y= y+x);
}
System.out.println(y-1);
}
}
package de.codegym.task.task04.task0442;
/*
Addieren
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//schreib hier deinen Code
int x = 0;
int y = 0;
while (true){
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
int x = Integer.parseInt(s);
if (x == -1);
break;
else (y= y+x);
}
System.out.println(y-1);
}
}