. Write a program that allows a small business owner to input, in parallel arrays, the type of item, its cost, and the number in stock. The program should output this information in the form of a table. You can assume that columns will be correctly formatted at a later time. The output will look something like this:
no example shown
you can find code snippets online that do just this kind of thing.
Write a program that allows a small business owner to input, in parallel arrays, the type of item, its cost, and the number in stock. The program should output this information in the form of a table. You can assume that columns will be correctly formatted at later time.
Sure, I can help you with that. Here's a step-by-step guide on how to write a Python program that allows a small business owner to input and display information in parallel arrays:
Step 1: Declare empty arrays to store the item type, cost, and quantity in stock.
```
item_types = []
costs = []
quantities = []
```
Step 2: Prompt the user to enter the information for each item in a loop, and store it in the respective arrays.
```
while True:
item_type = input("Enter the item type (or 'q' to quit): ")
if item_type == 'q':
break
cost = float(input("Enter the cost: "))
quantity = int(input("Enter the quantity in stock: "))
item_types.append(item_type)
costs.append(cost)
quantities.append(quantity)
```
Step 3: Display the information in a table format using a loop.
```
print("Item Type\tCost\tQuantity")
print("---------------------------------------")
for i in range(len(item_types)):
print(f"{item_types[i]}\t\t{costs[i]}\t{quantities[i]}")
```
Here's the complete program:
```python
item_types = []
costs = []
quantities = []
while True:
item_type = input("Enter the item type (or 'q' to quit): ")
if item_type == 'q':
break
cost = float(input("Enter the cost: "))
quantity = int(input("Enter the quantity in stock: "))
item_types.append(item_type)
costs.append(cost)
quantities.append(quantity)
print("Item Type\tCost\tQuantity")
print("---------------------------------------")
for i in range(len(item_types)):
print(f"{item_types[i]}\t\t{costs[i]}\t{quantities[i]}")
```
You can run this program and input the required information for each item. After entering all the items, it will display the information in a table format as you need.