This forum is now read-only. Please use our new forums! Go to forums
Equation
I don’t exactly understand why I am adding the variable “meal twice”? Don’t we just need it once.
Answer 53cd9fe780ff33bd81000003
You are not adding the meal twice. There are three items that make up the total cost.
- meal
- tax
- tip
Tax is a ‘portion’ of the meal (6.75% or 0.0675 ) we will use 0.0675 as that is the actual ratio of tax cost to meal cost ( tc / mc = 0.0675) and will be the actual number that one would need to multiply with the meal cost to get the tax amount.
The tip is the ‘portion’ of the meal + tax (15% or 0.15) again we are using 0.15 because that is the actual ratio of tip cost to meal + tax cost (tipc/(mc+tc).
Above you will see that the tax and the tip are both dependent on the price of the meal. Therefore you will need the meal price to compute the tax portion. Also you will need the meal+tax price to compute the tip. So putting all of that together we get
total = (meal + (meal * tax)) + (meal + (meal * tax)*tip)
or the less convoluted way below
meal = meal + meal * tax
Using this new meal value we proceed to this
total = meal + (meal*tip) # here you are not adding meal again but rather the amount that arises from multiplying the meal with the tip ‘ratio’ with the new meal price that was calculated above.
Does that Make sense? I feel like a rambled a bit.
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
2 comments
This also confused me at first. Can parentheses be used for order of operations?
I don’t see why not