Why do we add meal + meal?


#1



My code isn't incorrect.

I'm just confused as to why we add meal + meal = meal. (meal = meal + meal * tax)



#2

Let's say a = 50.

a = 50

To multiply this by a fraction, and add the two together, we could write it like so,

a = a + a * 0.5

Now when we print a it will be 75

print a    # 75

Why?

a = 50 + 50 * 0.5
a = 50 + 25
   == 75

Recall that multiplication takes precedence to addition, so that multiplication takes place first, then the addition.


#3

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