Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Below is the simple Python program named lastnamefirstnameifnestedpy that follows the specified inst... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

Students also viewed these Programming questions

Question

How do you join tables in an Access query?

Answered: 1 week ago