# Calculation issue

Can anyone guide me that what I am doing wrong for calculation

‘Calculation cash and chq’

Example net_total = 945 , so 945 - 200 will be 745 will store in cash_amount , but below calculation is ot working

cash_amount = (((net_total) - 200))

chq_amount = ((net_total) - cash_amount)

Hi @noor.ahmed, you need to convert your String to a Numeric. Check this out: https://www.phind.com/search?q=string%20toInteger%20groovy&source=searchbox

is there any simple way to do it ?

This should give you a starting point.

``````//Converting strings to numbers
def net_total = '945' as int
def cash_amt = '200' as int
def chq_amount = net_total - cash_amt
println('chq_amount: ' + chq_amount)

//Result: chq_amount: 745
``````
``````//Converting strings with decimals
def netTotal = '100,000.50'
netTotal = netTotal.replace(',', '')
BigDecimal netTotalDec = new BigDecimal(netTotal)
def cashAmt = '100,000.50'
cashAmt = cashAmt.replace(',', '')
BigDecimal cashAmtDec = new BigDecimal(cashAmt)
println('netTotalDec: ' + netTotalDec + ' cashAmtDec: ' + cashAmtDec)
def chqAmount = netTotalDec - cashAmtDec
println('chqAmount: ' + chqAmount)

//Result:
//netTotalDec: 100000.50 cashAmtDec: 100000.50
//chqAmount: 0.00
``````

Hi @noor.ahmed,

Just checking in to see if Dave’s comment has been able to help you or not. Do remember to follow up with him until you reach a solution.

Thanks! 