How I can store the BigDecimal() same as input?
I need to store real numbers using BigDecimal() which may contain following:
02.34
0.12
.12
0
000.000
I used the following approach :
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
BigDecimal[] amount = new BigDecimal[n];
for(int i=0;i<n;i++) {
amount[i]=sc.nextBigDecimal();
}
But while printing, it prints formatted. Like this:
2.34
0.12
0.12
0.000
0
I want it should be same as inputted. Therefore please let me know that how could I manage to store inputs intact.