Ask your own question, for FREE!
Computer Science 10 Online
jagr2713 (jagr2713):

Can someone help me D: It says its wrong but idk why https://gyazo.com/d1ed928d0ebe3fc417aa91fe39179192

OpenStudy (anonymous):

I think you want meal = meal + meal * tax to add the tax and then meal = meal + meal * tip to add the tip. also, use your variables. don't just type total = 44.50 + ... I guess what you also need to figure out first is whether the tax and tip are added to the meal or the tip is added to the total after the tax is added or the tax is added after the tip is added. I would imagine that the tip is not taxed as a portion of the meal. But do you pay tip on the tax? If the answer is no, the answer changes slightly. Your answer would add tax and tip in one go assuming you don't tip on the tax. Something like meal = meal * (1 + tax + tip). If you do pay tip the tax, then I'd do what I showed at the top. I really doubt you'd add tip first and then pay tax on the tip. If that's the case, first add the tip and then the tax.

OpenStudy (anonymous):

oh god that was so wrong. \[total = meal + meal * tip\] that's what you need to write. I didn't read the instructions. Sorry about that.

OpenStudy (kva1992):

yeah so what kus said: Here is what it should look like: meal = 44.50 tax = 0.0675 tip = 0.15 total = meal + meal * tip print("%.2f" % total)

OpenStudy (mathmate):

I think the instruction meant to put tip after taxes, otherwise the tax will not be calculated. That makes meal=meal+meal*tax meal=meal+meal*tip It is also customary to write equivalently meal=meal*(1+tax) meal=meal*(1+tip) or even meal=meal*(1+tax)*(1+tip) to avoid repetition of writing "meal" many times.

OpenStudy (kva1992):

if mathmate has it right then i would say use the last one because if not you would be overwriting the variable making the first declaration of the variable pointless

OpenStudy (mathmate):

@kval1992 Good catch! Actually, it should be total=meal*(1+tax)*(1+tip)

OpenStudy (kva1992):

@mathmate Yeah that sounds a bit more accurate

OpenStudy (mathmate):

@kva1992 :)

jagr2713 (jagr2713):

Thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!