Question: Write a program named lastname _ firstname _if_nested.py that does the following: Ask user for a unit price of an item. If the price is

Write a program named lastname_firstname_if_nested.py that does the following:

  • Ask user for a unit price of an item.
  • If the price is greater than zero:
    • Ask user for quantity to purchase (integer).
    • If the quantity is greater than zero:
      • Calculate subtotal (quantity times unit price), tax at 7.5%, and total.
      • Print the subtotal, tax, and total, properly labeled with exactly two digits to the right of the decimal point.
    • otherwise:
      • print an error telling the customer that the quantity must be greater than zero
  • otherwise:
    • print an error telling the customer that the unit price must be greater than zero

Your program will, therefore, have nested if statements. Notice that the preceding instructions give you a very large hint about how to structure your code!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Below is the simple Python program named lastnamefirstnameifnestedpy that follows the specified inst... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!