This forum is now read-only. Please use our new forums! Go to forums
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
@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
.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
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^