This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Milan Miladinovic
over 8 years

5/5 Got it right, just curious.

Why do you do meal = meal + meal * tax total = meal + meal*tip Why would you add meal twice? Is it 2 meals? I’m confused.

Answer 55b0b1bf9113cb98d700077a

3 votes

Permalink

@lolB888,

The following statement replaces the value of meal with the value of meal plus the amount of the tax. The amount of the tax is the original value of meal multiplied by the tax rate, which was previously assigned to the variable, tax. Since tax represents the tax rate, the quantity meal * tax represents the amount of the tax.

meal = meal + meal * tax

Then, this statement adds the tip to the current value of meal, which includes the tax, and assigns the result to total. Since tip represents the tip rate, the quantity meal * tip represents the amount of the tip.

total = meal + meal*tip

So, meal is not being added in twice. Instead, the value of meal is being used to compute and add the tax and then the tip to previous values of meal.

points
Submitted by Glenn Richard
over 8 years

1 comments

seanmcchapman over 8 years

I had the same problem no understanding. maybe simplifying it or make an example to help better understand this. no need to, but would help ^M^