# gpa.py
#    Program to find student with highest GPA
import string

class Student:

    def __init__(self, name, hours, qpoints):
        self.name = name
        self.hours = float(hours)
        self.qpoints = float(qpoints)

    def getName(self):
        return self.name

    def getHours(self):
        return self.hours

    def getQPoints(self):
        return self.qpoints

    def gpa(self):
        return self.qpoints/self.hours

def makeStudent(infoStr):
    name, hours, qpoints = string.split(infoStr,"\t")
    return Student(name, hours, qpoints)

def main():
    # open the input file for reading
    filename = raw_input("Enter name the grade file: ")
    infile = open(filename, 'r')

    # set best to the record for the first student in the file
    best = makeStudent(infile.readline())

    # process subsequent lines of the file
    for line in infile:
        # turn the line into a student record
        s = makeStudent(line)
        # if this is the best student so far, remember it.
        if s.gpa() > best.gpa():
            best = s
            
    infile.close()

    # print information about the student
    print "The best student is:", best.getName()
    print "hours:", best.getHours()
    print "GPA:", best.gpa()

if __name__ == '__main__':
    main()

