calculate upgradeCost