# Studenet name: Jiaxin Lin
# MacID: linj33
# Student number: 1311752
# Date: 2014/2/25

from graphics import *

def main():
    name=raw_input("Please enther the file name: ")
    unit,average= processFile(name)
    window=GraphWin("W",500,500)
    printOutputGUI(window, unit,average)


def processFile(name):
    infile=open(name,'r')
    pFile=infile.readlines()
    
    
    U=0
    y=0
    for i in range (len(pFile)):
        pFile[i]=(pFile[i].split())
        U=U+float(pFile[i][1])
        y=y+(float(pFile[i][1]))*(float(pFile[i][2]))
    A=y/U   
    return U,A

def printOutputGUI (win,unit,average):
    sentence=Text(Point(250,250),str(unit)+"\n"+str(average))
    sentence.setSize(13)
    sentence.setTextColor("blue")
    sentence.draw(win)
    win.getMouse()
    win.close()
