Question

In: Computer Science

v Write a program that calculates and displays different suggested tip amounts, much like you see...

v

Write a program that calculates and displays different suggested tip amounts, much like you see at the bottom of restaurant bills. Here is a sample execution:

Sample Execution:

Enter the total bill amount: $50
Suggested Tip Amounts:
10%: $5.00(for okay service)
15%: $7.50(for good service)
20%: $10.00(for great service)
Total with tip: $57.50

Requirements:

  • 2 pts - When you name your file use your last name – for example: LastNameHW04.py

  • 3 pts - Place a comment at the top of your code with your name and the purpose of the program.

  • 10 pts - The program should start by asking the user for input exactly in the form

    below. Their response (input) should be stored in a variable. The amount they enter should be converted to a float in order to allow for decimals to be entered and to do math using it.

              Enter the total bill amount: $
    
  • 15 pts - Use three lines of code to store the 10%, 15% and 20% tip values into three different variables.

  • 10 pts - Variables names must follow Python standard naming conventions.

  • 5 pts – For output, the program should first display the statement below on one line:

              Suggested Tip Amounts:
    
  • 30 pts – Next, use three lines of code to print the calculated tip amounts exactly as shown below. There should not be a space after the $, and to output the % symbol, enter %%. The values in red below will vary based on the user input:

    10%: $5.00(for okay service) 15%: $7.50(for good service) 20%: $10.00(for great service)

  • 5 pts - Include additional comments throughout your code explaining what your code does. Remember comments start with #.

  • 20 pts - Extend the program to output an addendum to the receipt that adds a mandatory 15% tip to the total bill amount. You will need an additional variable to store the final cost after adding the tip to the toal bill amount. Output the final total.

Prompt for input

Example of Input: 50

Total with tip: $57.50

Solutions

Expert Solution

"""
Name: Your Name
This program calculates tip amounts on a bill amount
"""

# Ask user to enter bill amount, convert it into float before storing in variables
bill_amount = float(input('Enter the total bill amount: $'))

# Calculate tip amount with 10%, 15%, 20% tip
ten_percent_tip = bill_amount * 10 / 100
fifteen_percent_tip = bill_amount * 15 / 100
twenty_percent_tip = bill_amount * 20 / 100

# Print tip amounts
print('Suggested Tip Amounts:')
print('10%%: $%0.2f(for okay service)' % ten_percent_tip)
print('15%%: $%0.2f(for good service)' % fifteen_percent_tip)
print('20%%: $%0.2f(for great service)' % twenty_percent_tip)

# Calculate mandatory tip - 15%
mandatory_tip = bill_amount * 15 / 100
total_bill_with_tip = bill_amount + mandatory_tip

# Print total bill
print('Total with tip: $%0.2f' % total_bill_with_tip)

SCREENSHOT


OUTPUT


Related Solutions

Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Write a program named MakeChange that calculates and displays the conversion of an entered number of...
Write a program named MakeChange that calculates and displays the conversion of an entered number of dollars into currency denominations—twenties, tens, fives, and ones. For example, if 113 dollars is entered, the output would be twenties: 5 tens: 1 fives: 0 ones: 3. Answer in C# (P.S i'm posting the incomplete code that i have so far below.) using System; using static System.Console; class MakeChange { static void Main() { int twenties, tens, fives, ones; WriteLine("Enter the number of dollars:");...
Answer question in Python, show all code: Write a program that calculates and displays the end...
Answer question in Python, show all code: Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed...
Please use Java language! with as much as comment! thanks! Write a program that displays a...
Please use Java language! with as much as comment! thanks! Write a program that displays a frame with a three labels and three textfields. The labels should be "width:", "height:", and "title:" and should each be followed by one textfield. The texfields should be initialized with default values (Example 400, 600, default title), but should be edited by the user. There should be a button (label it whatever you want, I don't care). If you click the button, a new...
Please use Java language! with as much as comment! thanks! Write a program that displays a...
Please use Java language! with as much as comment! thanks! Write a program that displays a frame with a three labels and three textfields. The labels should be "width:", "height:", and "title:" and should each be followed by one textfield. The texfields should be initialized with default values (Example 400, 600, default title), but should be edited by the user. There should be a button (label it whatever you want, I don't care). If you click the button, a new...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed. b.Modify the program in Exercise 2a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method. c.Modify the program in Exercise 2b so that...
President Clinton's crime bill from 1994 suggested a federal program that worked much like a price...
President Clinton's crime bill from 1994 suggested a federal program that worked much like a price subsidy; the federal government would augment local government expenditures on police with additional funds from the federal treasury. (Assume police services is a normal good). A. Draw an indifference curve diagram that depicts the changes in consumption of Police Services (x-axis please) and all other goods that occurs when the government first offers a police services subsidy to a state. B. Congressional Republicans wanted...
DESIGH A FLOWCHART IN FLOWGORITHM Speeding Violation Calculator. Design a program that calculates and displays the...
DESIGH A FLOWCHART IN FLOWGORITHM Speeding Violation Calculator. Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speed limit and the driver's speed. Validate the input as follows: The speed limit should be at least 20, but not greater than 70. The driver's speed should be at least the value entered for the speed limit (otherwise the driver was not...
in java Write a Java Program that displays a menu with five different options: 1. Lab...
in java Write a Java Program that displays a menu with five different options: 1. Lab Test Average Calculator 2. Dice Roll 3. Circle Area Calculator 4. Compute Distance 5. Quit The program will display a menu with each of the options above, and then ask the user to enter their choice. There is also a fifth option to quit, in which case, the program will simply display a goodbye message. Based on the user’s choice, one of the options...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula: BMI=Weight*703/Height^2. I need help making this to Java to just calculate BMI.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT