package pl.codegym.task.task04.task0442;
/*
Dodawanie
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//tutaj wpisz swój kod
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
while (true) {
int l = Integer.parseInt(reader.readLine());
sum += l;
System.out.println(sum);
if (l == (-1)) {
break;
}
}
}
}
Co jest nie tak?
Dyskutowane
Komentarze (5)
- Popularne
- Najnowsze
- Najstarsze
Musisz się zalogować, aby dodać komentarz
Norbert
5 lutego, 17:02
+1
Thomas
6 lutego, 08:46przydatny
with a do-while loop you'll need just one condition
+1
Norbert
7 lutego, 09:13
Sure, but it was a revised version of Magda's code
+1
Thomas
7 lutego, 10:04
Probably, but just posting the solution might not be too helpful. Instead, you could give the questioner some help and explanation so that he/she can code the solution themselves. If that still doesn't help, you can always post code fragments. The solution itself is now available to everyone. So to get it is not the big problem ;)
But that's just my humble opinion. You of course may see this different.
+1
Thomas
5 stycznia, 21:39przydatny
try to move the output outside the loop (btw. that's a classic for a do-while loop)
+1