Question

Python Simple Programming Write a program in Python that calculates the tip and total for a...

Python Simple Programming

Write a program in Python that calculates the tip and total for a meal at a restaurant.

When your program is run it should ...

  • Calculate the tip and total for a meal for a restaurant
  • Print the name of the application "Tip Calculator"
  • Get input from the user for cost of meal and tip percent
  • Print the tip and total amounts.
  • The formula for calculating the tip amount is: tip = cost of meal * (tip percent / 100)
  • The program should accept decimal entries like 52.31 and 15.5. Assume the user will enter valid data.
  • The program should round the results to a maximum of two decimal places

Running a Sample Program

Be sure to test your work so that it runs in a manner shown below.

The data I entered is in bold maroon... but your program should run
properly for any valid value entered by a user.

Tip Calculator

Cost of meal: 52.31

Tip percent: 20

Tip amount: 10.46

Total amount: 62.77

Use meaningful variable names (e.g. use firstname, not x)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

print('Tip Calculator')

cost_meal=float(input('Cost of meal: '))
tip_percent=float(input('Tip percent: '))
tip_amount=(tip_percent*cost_meal)/100
print('Tip amount: %0.3f' %(tip_amount))
total_amount=cost_meal+tip_amount
print('Total amount: %0.3f' %(total_amount))

Image of the Code:

Image of Input and Output:

Explanation:

  • First we took input from the user and converted into float.
  • Then we calculated the necessary values.
  • Then we printed the values upto 3 decimal places using 0.3f and % symbol.

If the answer helped please upvote. It means a lot. For any query comment below.

Add a comment
Know the answer?
Add Answer to:
Python Simple Programming Write a program in Python that calculates the tip and total for a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT