added method to calculate total cost. updated view.