How can i add $16.51 and $2.0

Hi ,

I followed checkout process and i fatched the value of item cost $16.51 and shipping cost $2.00 by using for loop, how can i store these value in variable. Second question how can i add these value ?


1 Like

see my comment

@Samta Sharma you need some core java language skills to do that, Follow below process

1. Remove leading $ sign

firstValue = $16.51
firstValue = firstValue.substring(1)

2. This will remove $, However that value will be still a string, So convert it into integer

int result1 = Integer.parseInt(firstValue)

3. Now add both value in third integer value, This will show final result.

4. If you have loop then declare variable outside loop to avoid errors, Or create dynamic variables which is quiet tricky.

Hi Dhaval,

Thank you so much for your answer. My issue got resolved