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 br = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br.readLine());
int total = 0;
String s = "sum";
while(1 == 1){
total += a;
a = 0;
String b = br.readLine();
if(b == s){
System.out.println(total); break;
}
else {total += Integer.parseInt(b);}
}
}
}
Whats wrong here? i think problem resides in line 24 but i cant solve it. Some help would be apreciated.
Resolved
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
anotherLearner
18 October 2018, 11:33solution
Resolved, use equals() to compare strings.
+2