Calculating cost and quantity