Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that computes how much a customer has to pay after purchasing two items. The price is calculated according to the following rules:

Write a program that computes how much a customer has to pay after purchasing two items. The price is calculated according to the following rules:

Buy one get one half off promotion: the lower price item is half price.

If the customer is club card member, additional 10% off.

Tax is added.

Inputs to the program include:

Two items prices

Have club card or not (User enters Y or y for yes; N or n for no)

Tax rate (User enters the percentage as a number; for example they enter 8.25 if the tax

rate is 8.25%)

For example, an execution could look like this: Enter price of first item: 10 Enter price of second item: 20 Does customer have a club card? (Y/N): Y

Enter tax rate, e.g. 5.5 for 5.5% tax: 8.25 Base price = 30.0 Price after discounts = 22.5 Total price = 24.36

And this is what i wrote:

first=int(input("Enter price of first item:")) second=int(input("Enter price of second item:")) club=input("Does customer have a club card?(Y/N):") tax=float(input("Enter tax rate, e.g. 5.5 for 5.5% tax:")) print("Base price="+str(first+second)) if first >= second and club == "Y": priceafterd=print("Price after discount="+str((first+0.5*second)*0.9)) print("Total price="+str(priceafterd*(1+tax/100))) elif second >= first and club == "Y": priceafterd=print("Price after discount="+str((second+0.5*first)*0.9)) print("Total price="+str(priceafterd*(1+tax/100))) elif first >= second and club == "N": priceafterd=print("Price after discount="+str(first+0.5*second)) print("Total price="+str(priceafterd*(1+tax/100))) else: priceafterd=print("Price after discount="+str(second+0.5*first)) print("Total price="+str(priceafterd*(1+tax/100)))

But there is a mistake, python shows

Traceback (most recent call last): File "/Users/jinkui/Documents/kj1143_hw3_q1.py", line 11, in print("Total price="+str(priceafterd*(1+tax/100))) TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

please help

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago