Question

Python Programming: Create a program that calculates three options for an appropriate tip to leave after...

Python Programming: Create a program that calculates three options for an appropriate tip to leave after a meal at a restaurant and repeats if the user enters "y" or "Y" to continue.

  • Print the name of the application "Tip Calculator"
  • Get input from the user for "Cost of meal: "
  • Calculate and display the "Tip Amount" and "Total Amount" at a tip_percent of 15%, 20%, and 25%.
    • Use a FOR loop to iterate through the tip_percent
    • The formula for calculating the tip amount is: tip = cost of meal * (tip percent / 100)
    • The program should accept decimal entries like 52.31. Assume the user will enter valid data.
    • The program should round the results to a maximum of two decimal places
  • At the "Continue? (y/n)" prompt, the program should continue only if the user enters “y” or “Y” to continue.
  • Print "Bye!" or a salutation at the end of the program

Tip Calculator

Cost of meal: 52.31

15%
Tip amount: 7.85
Total amount: 60.16

20%
Tip amount: 10.46
Total amount: 62.77

25%
Tip amount: 13.08
Total amount: 65.39

Continue (y/n)?: y

Cost of meal: 23.60

15%
Tip amount: 3.54
Total amount: 27.14

20%
Tip amount: 4.72
Total amount: 28.32

25%
Tip amount: 5.9
Total amount: 29.5

Continue (y/n)?: n

Bye!

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

Solution:

Raw code:

print("Tip Calculator")
tips=[15,20,25] #list for tips
cost=float(input("Cost of meal:")) #taking float input
for i in tips: #looping over tips list
print('{}%'.format(i)) #to print %
tip_amount=cost*(i/100) #calculating tip amount
tip_amount=round(tip_amount,2) #rounding upto 2 decimals
print("Tip amount:{}".format(tip_amount))
total_amount=cost+tip_amount #calculating total amount
total_amount=round(total_amount,2)
print("Total amount:{}".format(total_amount))
while (True):
choice=input("Continue(y/n)?:").lower() #taking input and converting to lowercase
if choice=='y':
cost=float(input("Cost of meal:")) #repeating the same process
for i in tips:
print('{}%'.format(i))
tip_amount=cost*(i/100)
tip_amount=round(tip_amount,2)
print("Tip amount:{}".format(tip_amount))
total_amount=cost+tip_amount
total_amount=round(total_amount,2)
print("Total amount:{}".format(total_amount))
  
else: #if choice is not y or Y then stoping the loop using break
print("Bye!")
break

Hope you understand.if you have any doubts or if you want any modifications please comment.

Thank you .Upvote me.

Add a comment
Know the answer?
Add Answer to:
Python Programming: Create a program that calculates three options for an appropriate tip to leave after...
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
  • 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...

  • (COs 1 and 8) Create a Python program that calculates the tip and total for a...

    (COs 1 and 8) Create a Python program that calculates the tip and total for a meal at a restaurant. Paste Python code here; output not required. Sample output: Tip Calculator Enter cost of meal: 52.31 Enter tip percent: 20 Tip amount: 10.46 Total amount: 62.77 Specifications: •Input: costOfMeal, tipPercent         The formula for calculating the tip amount is: tip = costOfMeal * (tipPercent / 100) •         The program should accept decimal entries like 52.31 and 15.5. •         Assume the user...

  • *Create in Python 3: Change Calculator Create a program that calculates the coins needed to make...

    *Create in Python 3: Change Calculator Create a program that calculates the coins needed to make change for the specified number of cents. Sample Console Output Change Calculator   Enter number of cents (0-99): 99 Quarters: 3 Dimes: 2 Nickels: 0 Pennies: 4   Continue? (y/n): y Enter number of cents (0-99): 55   Quarters: 2 Dimes: 0 Nickels: 1 Pennies: 0   Continue? (y/n): n   Bye! Specifications The program should display the minimum number of quarters, dimes, nickels, and pennies that one needs...

  • Language - PYTHON Design a program that calculates the total amount of a meal purchased at a restaurant

    Language - PYTHONDesign a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15% tip and 7% sales tax. Display each of these amounts and the total.Please help, I have no idea where to begin. Thanks

  • Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill...

    Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill amount from the command-line, then show 3 tip amounts: 15%, 20% and 25% of the bill. Don't worry about rounding the result to two decimal places, but make sure that the result includes cents (not just dollars). This program will be different than your first Tipcalc program because you will writea method to calculate the tip amount. program will have 2 methods: main) and...

  • Create a program that calculates the area of various shapes. Console Specifications Create an abstract class...

    Create a program that calculates the area of various shapes. Console Specifications Create an abstract class named Shape. This class should contain virtual member function named get_area() that returns a double type. Create a class named Circle that inherits the Shape class and contains these constructors and member functions: Circle(double radius) double get_radius() void set_radius(double radius) double get_area() Create a class named Square that inherits the Shape class and contains these constructors and member functions: Square(double width) double get_width() void...

  • Project 5 - intro to python Write a program in python that calculates the amount of...

    Project 5 - intro to python Write a program in python that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, four pennies the third day, and continues to double each day. Output the amount earned each day .. and the total pay at the end. The Algorithm (Plan) for your program would be: Ask the user for the...

  • Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate....

    Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate. ·         The application calculates the interest amount and formats the loan amount, interest rate, and interest amount. Then, it displays the formatted results to the user. ·         The application prompts the user to continue. ·         The program stops prompting the user for values after taking 3 loan amounts. ·         The application calculates and displays the total loan and interest amount and ends the program Example Output Welcome to...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • This is done in c programming and i have the code for the programs that it wants at the bottom i ...

    This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions Program 2:Tip,Tax,Total int main(void) {    // Constant and Variable Declarations    double costTotal= 0;    double taxTotal = 0;    double totalBill = 0;    double tipPercent = 0;    // *** Your program goes here ***    printf("Enter amount of the bill: $");    scanf("%lf", &costTotal);    printf("\n");    // *** processing ***    taxTotal = 0.07 * costTotal;    totalBill...

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