Question

Create a program using Payton that determines the cost of 3 items shipped with tax. The...

Create a program using Payton that determines the cost of 3 items shipped with tax.
The user will enter the following information for exactly 3 different items:

  • Description
  • Price
  • Quantity
  • Weight per item

You will capture the 4 pieces of information for each of the 3 items. You will then let the user know what they bought, how much is the SubTotal, Shipping & Handling costs, the Tax and the Total (format the output for these 4 totals as USD$ with two decimal places)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Problem by using an example

#code

#number of items
n=3
#list to store item names
items=[]
#to store sub total
sub_total=0
#to store shipping cost, $5 is fixed basic charge
shipping=5
#looping for n times
for i in range(n):
#prompting and reading all inputs
print('Item ',(i+1))
desc=input('Enter item description: ')
price=float(input('Enter item price: '))
quantity = int(input('Enter item quantity: '))
weight = float(input('Enter item weight (pounds): '))
#multiplying price and quantity, adding to sub total
sub_total+=price*quantity
#multiplying weight and quantity and 0.25, to get shipping cost, adding
#to shipping
shipping+=weight*0.25*quantity
#appending item name to items
items.append(desc)

#finding 9% of sub total as tax
tax=sub_total*0.09
#adding everything to get final total
total=sub_total+tax+shipping
#displaying everything in proper format.
#' '.join(items) will combine elements in a string list space separated
#{:.2f} will format a numeric value to 2 digits after decimal point
print("You have purchased: {}, The subtotal is ${:.2f}".format(' '.join(items),sub_total))
print("The Shipping and Handling costs are ${:.2f}".format(shipping))
print("The Tax is ${:.2f} The Total is ${:.2f}".format(tax,total))

#output

Item 1

Enter item description: Shovel

Enter item price: 25

Enter item quantity: 2

Enter item weight (pounds): 6

Item 2

Enter item description: Planter

Enter item price: 45

Enter item quantity: 2

Enter item weight (pounds): 11

Item 3

Enter item description: Broom

Enter item price: 12

Enter item quantity: 1

Enter item weight (pounds): 4

You have purchased: Shovel Planter Broom, The subtotal is $152.00

The Shipping and Handling costs are $14.50

The Tax is $13.68 The Total is $180.18

Add a comment
Know the answer?
Add Answer to:
Create a program using Payton that determines the cost of 3 items shipped with tax. The...
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
  • 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...

  • Question 1 CSEB113 Write a program to create customer's bll for an electrical appliance company. Assume...

    Question 1 CSEB113 Write a program to create customer's bll for an electrical appliance company. Assume the company sells only three different products: TV, VCR and CD player. The unit prices are RM3000, RM500 and RM300 respectively. The program must read the quantity of each piece of the items purchased from the user. It then calculates the cost of each item, the subtotal and the total cost after an 6% of GST. Your program must use the following functions, given...

  • I need help building code in python for this: Create a program that: Creates a sales...

    I need help building code in python for this: Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file...

  • Please implement the following only using Javascript. design a cash register class that can be used...

    Please implement the following only using Javascript. design a cash register class that can be used with inventory item class. The cash register class needs to: 1. ask user for item and quantity being purchased. 2. get the items cost from inventory item object 3. add 30% profit to the cost to get the items unit price 4. multiply the unit price times the quantity being purchased to get purchase subtotal 5. compute a 6% sales tax on the subtotal...

  • In this project you will write a C++ program that simulates the purchase of a single...

    In this project you will write a C++ program that simulates the purchase of a single item in an online store. What to do Write a C++ program that: 1. Prints out a welcome message. 2. Prompts the user for the following information: (a) Their first name (example: Roger) (b) Their last name (example: Waters) (c) The name of the product (example: Brick) (d) The unit price of the product (example: 1.99) (e) The quantity to buy (example: 200) (f)...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • Write the following program in Java using Eclipse. A cash register is used in retail stores...

    Write the following program in Java using Eclipse. A cash register is used in retail stores to help clerks enter a number of items and calculate their subtotal and total. It usually prints a receipt with all the items in some format. Design a Receipt class and Item class. In general, one receipt can contain multiple items. Here is what you should have in the Receipt class: numberOfItems: this variable will keep track of the number of items added to...

  • Language = Java Create a program to receive book prices until a sentinel value is entered....

    Language = Java Create a program to receive book prices until a sentinel value is entered. (Be sure to tell your user what the sentinel value is so they can type it to indicate they are finished with entering input.) After the sentinel value is entered, compute the total book order total and return the following to the user. As book prices are entered, you'll need to have some way to capture the number of books they ordered and the...

  • This question is for Python 3. I can get the first couple of steps in this...

    This question is for Python 3. I can get the first couple of steps in this question but I get errors. Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save...

  • In this assignment, you will develop a C++ program which calculates a shipping charge and determines...

    In this assignment, you will develop a C++ program which calculates a shipping charge and determines the “type of trip” for a freight shipping company. Ask the user to enter the distance a package is to be shipped, and use a menu and a switch statement to determine the rate based on the package’s weight. Then display the shipping charge and using the table in #7 below, display the type of trip. Below is the chart to use to calculate...

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