Reassingning Meal


#1

Why reassign meal if when you have to type total you have to write it out yourself.
TOTAL = MEAL + MEAL * TAX(THATS WHAT WE HAV TO DO)
Why cant we just type TOTAL = MEAL(AS WE RE ASSOGNED MEAL TO MEAL + MEAL * TAX AVOVE ANYWAY)


#2

meal * tax is the amount of tax paid on the meal price. We need to reflect both the meal price and the tax amount, so add them.

tax_due = meal * tax
total = meal + tax_due

but tax_due is equal to meal * tax so,

total = meal + meal * tax

multiplication comes before addition so the tax is calculated first, then added.


#3

I think you missed something. The assignment of total is that of the meal cost and the tip, if you set total equal to meal then you are not leaving a tip.

Assign the variable total to the sum of meal + meal * tip on line 8. Now you have the total cost of your meal!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.