This forum is now read-only. Please use our new forums! Go to forums
why do I type meal twice?
Total is calculated by coding:
total = meal + meal * tip
why is it not just:
total = meal * tip
it seems like two meals is redundant?
Answer 54ccf36951b887dd82001272
The reason for this …
total = meal + meal * tip
… is that to get the total
cost, we need to take the entire meal
cost so far (prior to the tip), which is meal
, and then add to that an additional percentage of the meal
cost, based on the tip
rate. So the actual tip that is paid is meal * tip
. Adding the whole pre-tip meal
cost to the actual tip, then becomes meal + meal * tip
.
Answer 54ccd65986f552898a0010ec
I think the main reason they have the calculation in that manner is more for the display of calculation ability of the script, don’t let that bother you now. your going to have fun later nutting out some of the stuff that comes up
enjoy :)
hope this helps?
1 comments
tx!
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
tx!