I remember a similar exercise one or two levels back but for the life of me I cant remember the exact way to print an ongoing addition of all numbers input into the console. Please if someone can either give me a solution I can reverse engineer and or talk me through the exercise that would be awesome.
package com.codegym.task.task05.task0529;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Console-based piggy bank
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int sum;
while (true) {
String s = bufferedReader.readLine();
sum = Integer.valueOf(s);
if (s.equals("exit")) {
break;
} else if (s.equals("sum")) {
break;
} else {
System.out.println(s);
}
}
}
}