# ECE 2524 Homework 3 Problem 2 Glen Polo

import sys
if len(sys.argv) == 2:
	print "ACCOUNT SUMMARY"
	x = open(sys.argv[1], 'r')
	priceMatrice = []
	for line in x: 
		x = line.split()
		#lastName = line.rsplit()[1]	
		priceMatrice.append(float(x[2]))
		maxPrice = max(priceMatrice)
		minPrice = min(priceMatrice)
		totalPrice = sum(priceMatrice)
		averagePrice = sum(priceMatrice)/len(priceMatrice)
		if max(priceMatrice) == float(x[2]):
			lastNameMax = line.rsplit()[1]			
		if min(priceMatrice) == float(x[2]):
			lastNameMin = line.rsplit()[1]
		

	print "Total amount owed = " , totalPrice
	print "Average amount owed = " , averagePrice
	print "Maximum amount owed = " , maxPrice , "by " , lastNameMax
	print "Minimum amount owed = " , minPrice , "by " , lastNameMin




