Calculating cost and profit