Question: This is for python 3.5.2 version and I use pyCharm program. You will create a program that will take comma delimited input for the inventory

This is for python 3.5.2 version and I use pyCharm program.

You will create a program that will take comma delimited input for the inventory of a small computer store. Information stored in the comma delimited file include the product name, # of items on hand, and wholesale cost. Extend the value of each item and provide the total value of the inventory. A file with input and expected output is attached.

Make sure you strip all leading and following spaces. Use conversion specifiers, flags and field width specifiers as needed.

Use internal documentation, good prompts to the user, and meaningful variable.

These are input and output.

Input CD-R 100 disc, 25, 14.00 ,DVD-R 50 disc,10, 10.00 , HDMI cable 3ft,12, 4.00 ,Flash Drive 32GB ,16, 9.00 , Laptop Cooling Pad ,10, 25.00  
Ending display: CD-R 100 disc 25 14.00 $350.00 DVD-R 50 disc 10 10.00 $100.00 HDMI cable 3ft 12 4.00 $48.00 Flash Drive 32GB 16 9.00 $144.00 Laptop Cooling Pad 10 25.00 $250.00 The total value of the inventory is $892.00. 

I have some errors on my code.

def main(): file = open("d:\Python\store.txt", "r") data = file.readlines() data = data[0].strip() file.close() inventory = data.split(",") i = 0 inventoryTotal = 0 while i < len(inventory): name = inventory[i].strip() itemCnt = int(inventory[i + 1].strip()) unitPrice = float(inventory[i + 2].strip()) itemTotalPrice = itemCnt * unitPrice inventoryTotal += itemTotalPrice print("  %-30s %-5d %-10.2f $%5.2f " % (name, itemCnt, unitPrice, itemTotalPrice)) i = i + 3 print("  The total value of the inventory is $%.2f  " % (inventoryTotal)) main() 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!