# functions def display_inventory(inv_type, chunky, skybar, valomilk, zagnut): print() print(inv_type.capitalize() + ' inventory') print('-----------------') print('{:8s} {:8d}'.format('Chunky', chunky)) print('{:8s} {:8d}'.format('Skybar', skybar)) print('{:8s} {:8d}'.format('Valomilk', valomilk)) print('{:8s} {:8d}'.format('zagnut', zagnut)) print('-----------------') # main algorithm # read names of data files initial_inventory = input('Name of file with the week\'s initial inventory: ') transactions = input('Name of file with the week\'s transactions : ') updated_inventory = input('Name of file with the week\'s updated inventory: ') # read beginning inventory file # this could be a function that returns a comma-separated string initial_inventory_file = open(initial_inventory, 'r') for line in initial_inventory_file: bar,count = line.strip().lower().split() if bar == 'chunky': chunky = int(count) elif bar == 'skybar': skybar = int(count) elif bar == 'valomilk': valomilk = int(count) else: # bar == 'zagnut': zagnut = int(count) initial_inventory_file.close() # display beginning inventory display_inventory('Initial', chunky, skybar, valomilk, zagnut) # process week's transactions # compute running total of change to each # count number of transactions of each type # display the number of transactions processed # display ending inventory # write ending inventory file