Question

his program sells only one thing. The Monkey King action figure. Users will be entering how...

his program sells only one thing. The Monkey King action figure. Users will be entering how many they want, if they want them gift wrapped, if they want it/them to be shipped, what state they live in and a Promo code (if they have one).

The figure sells for $12.00. Gift wrapping costs $4 for each figure. If they are going to have it shipped it will cost $7 (no matter how many they are ordering). If they have a Promo Code they will get 10% off the subtotal (quantity * price).

They will enter the two letter abbreviation for the State they live in.

You are to give them simple choices for 5 pieces of information you are collecting from them. You are collecting Yes/No's , a number, two letter state name, and possibly a Promo Code.

Here is an example of easy user entry. See how the user is given simple choices.

Input the payment method
'P' for PayPal
'C' for check, or
'CC' for Credit Card
The output for this program will be

The Subtotal in USD $ (2 decimal places)
The state the user lives in
The Total (subtotal plus any of the extra costs or discounts) in USD $ (2 decimal places)
use Payton program.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

python code for above question is attached below :-

# function to check for coupon code from the user
def check_promo(initial_amount,amount,s):
# taking user input yes or no
if s=='Y' or s=='y':
# if yes ask for coupon code
code = input('enter promo code of length 8: ')
# conditions for coupon code validation
if len(code)==8:
# calculating discount
discount = 0.1*initial_amount
return amount-discount
else: #if coupon code is invalid
# print invalid code and ask for coupon code again
print('invalid coupon code')
a = check_promo(initial_amount,amount,s)
return a
# if user enters no simply return the amount without discount
else:
return amount
  
# function to check the shipping details and amount
def check_shipping(amount,s):
# condition if user enters yes for shipping
if s=='Y' or s=='y':
return amount+7
else: #condition if user enters no for shipping
return amount
# function to check whether to gift wrap items
def check_gift_wrap(amount,s):
# condition for user entering yes for gift wrap
if s=='Y' or s=='y':
return amount+4
# else if users enters any other response return the amount without extra charge
else:
return amount
  
# function to print the final bill
def print_result(initial_amount,amount,state_name):
# printing subtotal without extra charges
print('The Subtotal is ${0:.2f}'.format(initial_amount))
print('The state the user lives in is:',state_name)   
# printing final total
print('The Total (subtotal plus any of the extra costs or discounts) in USD ${0:.2f}'.format(amount))

# taking user inputs
number_pieces = int(input('enter the number of items required: '))
initial_amount = number_pieces*12 #calculating the initial sub total
amount = number_pieces*12
gift_wrap = input('you want it to be gift wrapped(Y for yes and N for no): ') #asking for gift wrap
amount = check_gift_wrap(amount,gift_wrap) #amount after gift wrap
shipping = input('you want it to be shipped(Y for yes and N for no): ') #asking for shipping
amount = check_shipping(amount,shipping) #amount after shipping charges
state_name = input('Enter yor state name(enter two letter abbreviaiton of state name): ') #asking state name
promo = input('Do you have any promo code(Y for yes and N for no): ') #asking for any promo code
amount = check_promo(initial_amount,amount,promo) #amount after applying any promo code
print_result(initial_amount,amount,state_name) #printing the final bill

screenshot of the code for indentation reference : -

output : -

output 1 -

output 2 -

output 3 -

if my answer helped then please upvote and comment for any queries

thankyou !

Add a comment
Know the answer?
Add Answer to:
his program sells only one thing. The Monkey King action figure. Users will be entering how...
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
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