### 11821 - High-Precision Number

Posted:

**Thu Aug 21, 2014 7:26 pm**Can anybody please tell me what am I doing wrong here:

Code: Select all

```
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
public class Main {
static BigDecimal num, sum;
static String line;
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(input.readLine());
while (t > 0) {
sum = BigDecimal.ZERO;
while (input.ready()) {
line = input.readLine();
if(line.length() == 1 && line.charAt(0) == '0') {
break;
}
num = new BigDecimal(line);
sum = sum.add(num);
}
t--;
System.out.println(sum.stripTrailingZeros().toPlainString());
}
}
}
```