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 {
//write your code here
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
int x=0;
while(true){
String s=bf .readLine();
if(s.equals("sum") )
System.out.println("sum"+x) ;
break;
int num= Integer.parseInt(s) ;
x=x+num;
}
//System.out.println(x) ;
}
}
help...i'm stuck
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Anthony Chalk
27 December 2019, 12:50
Get rid of
And uncomment
0
Hendra
27 December 2019, 13:20
i have follow your instruction ,but the output display number format exception
0
Anthony Chalk
27 December 2019, 22:03
Try surrounding
with an else-if block 0