Formula For Total Cost