Driver code
var SP , profit , loss ; SP = 1020 ; profit = 20 ; document . write ( " " + CPwithProfit ( SP , profit ) + " " ) ; SP = 900 ; loss = 10 ; document . write ( " " + CPwithLoss ( SP , loss ) + " " ) ; SP = 42039 ; profit = 8 ; document . write ( " " + CPwithProfit ( SP , profit ) + " " ) ;