Aug-30-2017, 08:26 AM
Howdy y'all,
I am working from a self-teach book and at the end of chapter 2 I have been given the challenge of creating a tip calculator. It actually says: "Write a tipper program where the user enters a restaurant bill total. The program should then display two amounts: a 15% tip and a 20% tip.
In trying to challenge myself further I have expanded slightly on the request by calculating the sales tax and offering a third option
of a 10% tip.
I have the app working... acceptably with the exception that I can't get my calculations to display in typical 0.00 (dollar) format.
I have searched the internet and youtube for examples and even found a couple, however when I tried to apply them, I ended up with syntax errors. I suspect that I am jumping the gun and trying to do something more advanced than the book intended although it hasn't covered formatting yet, I'm not sure how this was supposed to work without it. I'm probably trying to make something relatively simple much more complicated than it needs to be, as usual.
I would greatly appreciate it if someone could offer me a suggestion or two to fix this issue.
Thanks!

I am working from a self-teach book and at the end of chapter 2 I have been given the challenge of creating a tip calculator. It actually says: "Write a tipper program where the user enters a restaurant bill total. The program should then display two amounts: a 15% tip and a 20% tip.
In trying to challenge myself further I have expanded slightly on the request by calculating the sales tax and offering a third option
of a 10% tip.
I have the app working... acceptably with the exception that I can't get my calculations to display in typical 0.00 (dollar) format.
I have searched the internet and youtube for examples and even found a couple, however when I tried to apply them, I ended up with syntax errors. I suspect that I am jumping the gun and trying to do something more advanced than the book intended although it hasn't covered formatting yet, I'm not sure how this was supposed to work without it. I'm probably trying to make something relatively simple much more complicated than it needs to be, as usual.

I would greatly appreciate it if someone could offer me a suggestion or two to fix this issue.
Thanks!
food = float(input('What is your food total?: ')) tax = 0.08 * food print('The sales tax is: $', tax) total = tax + food print('Your total bill comes to: $', total) tip10 = 0.10 * total tip15 = 0.15 * total tip20 = 0.20 * total print('To tip 10% the amount is: $', tip10) print('To tip 15% the amount is: $', tip15) print('To tip 20% the amount is: $', tip20)And here is an example of my output:
Output:What is your food total?: 56.85
The sales tax is: $ 4.548
Your total bill comes to: $ 61.398
To tip 10% the amount is: $ 6.139800000000001
To tip 15% the amount is: $ 9.2097
To tip 20% the amount is: $ 12.279600000000002
>>>
Quote:If you can't learn to do something well?... Learn to enjoy doing it poorly.