1.9k views
5 votes
Create a program that will compute the price for 5 different items. You need to request the item name, total number of items, and price of each item. Calculate the subtotal and multiply it by 8.25 percent sales tax, then have a grand total of all the purchases?

User Imaginary
by
7.9k points

1 Answer

2 votes

Final answer:

To create a program that computes the price for 5 different items, you can use a loop to iterate through each item and ask the user for the item name, total number of items, and price of each item.

Step-by-step explanation:

To create a program that computes the price for 5 different items, you can use a loop to iterate through each item and ask the user for the item name, total number of items, and price of each item.

You would then calculate the subtotal by multiplying the total number of items by the price for each item, and multiply it by the sales tax rate (8.25%). Finally, you would add the sales tax to the subtotal to get the grand total of all the purchases.

Here is an example of how you can implement this program in Python:



```python
subtotal = 0.0
for i in range(5):
item_name = input('Enter the item name: ')
total_items = int(input('Enter the total number of items: '))
item_price = float(input('Enter the price of each item: '))
subtotal += total_items * item_price

sales_tax = subtotal * 0.0825
grand_total = subtotal + sales_tax

print('Subtotal:', subtotal)
print('Sales Tax:', sales_tax)
print('Grand Total:', grand_total)
```

User Rovy
by
8.3k points