วันจันทร์ที่ 26 ตุลาคม พ.ศ. 2558

lab 7 display BMI

def setup():
    a = student("Giggs",20,180,60)
    b = student("Keane",18,165,90)
    c = student("Cole",21,185,74)
    d = student("Scholes",19,177,55)
    e = student("Park",18,175,46)
    a.show()
    b.show()
    c.show()
    d.show()
    e.show()
    print('BMI of',a.get_name(),calculation_of_bmi(a))
    print('BMI of',b.get_name(),calculation_of_bmi(b))
    print('BMI of',c.get_name(),calculation_of_bmi(c))
    print('BMI of',d.get_name(),calculation_of_bmi(d))
    print('BMI of',e.get_name(),calculation_of_bmi(e))
   
def calculation_of_bmi(student):
    highM = student.get_high()/100
    bmi = student.get_weight()/(highM*highM)
    return bmi
class student:

    def __init__(self,name,age,high,weight):
        self.name = name
        self.age = age
        self.weight = weight
        self.high = high
    def show(self):
        print(self.name, end = "  ")
        print(self.age, end = "  ")
        print(self.weight, end = "  ")
        print(self.high, end = "  ")
        print()
    def get_weight(self):
        return self.weight
    def get_high(self):
        return self.high      
    def get_name(self):
        return self.name      
setup()      
   
 
 
 
 
 
 
 
 
 
 
 
 

ไม่มีความคิดเห็น:

แสดงความคิดเห็น