82.3k views
4 votes
Which code successfully calculates and stores the final cost?

a) finalCost = baseCost + tax - discount
b) finalCost = baseCost * (1 + tax) - discount
c) finalCost = baseCost + (baseCost * tax) - discount
d) finalCost = baseCost * (1 - discount) + tax

User Wolfv
by
7.9k points

1 Answer

6 votes

Final answer:

The code that successfully calculates and stores the final cost is: finalCost = baseCost + (baseCost * tax) - discount. This code takes the base cost, adds the product of the base cost and the tax, and then subtracts the discount to calculate the final cost.

Step-by-step explanation:

The code that successfully calculates and stores the final cost is:

finalCost = baseCost + (baseCost * tax) - discount

This code takes the base cost, adds the product of the base cost and the tax, and then subtracts the discount to calculate the final cost. It correctly applies all the necessary operations to calculate the final cost.

User Xiaojin
by
8.0k points