You are on page 1of 4

CARTA ALIR MENGIRA BMI PELAJAR SEPERMAI

MULA

input berat (kg)

input tinggi (m)

set pengiraan_BMI

BMI<18.4 YA status kurang berat

TIDAK

18.5 < BMI <=24.9 YA status Normal

TIDAK

status Obesiti

Tamat
KOD ATURCARA MENGIRA BMI PELAJAR SEPERMAI

from tkinter import*

from tkinter.ttk import*

window=Tk()

def kira_BMI():

Berat=int(strTxtBerat.get())

Tinggi=float(strTxtTinggi.get())

BMI=Berat/(Tinggi**2)

strTxtBMI.set(round(BMI,2))

if BMI <18.4:

strLblMesej.set("Status Kurang Berat")

elif 18.5<= BMI <=24.9:

strLblMesej.set("Status Normal")

else:

strLblMesej.set("Status Obsetiti")

def kosongkan():

strTxtBerat.set("")

strTxtTinggi.set("")

strTxtBMI.set("")

strLblMesej.set("")

lblTajuk=Label(window, text="MENGIRA BMI")

lblTajuk.config(font=("Arial", 24))

lblTajuk.place(x=220, y=40)

lblBerat=Label(window, text="Berat (kg)")

lblBerat.place(x=100, y=120)

lblTinggi=Label(window, text="Tinggi (meter)")

lblTinggi.place(x=100, y=160)
lblBMI=Label(window, text="BMI")

lblBMI.place(x=100, y=200)

strTxtBerat= StringVar()

txtBerat=Entry(window, textvariable=strTxtBerat)

txtBerat.place(x=300, y=120, width=70, height=20)

strTxtTinggi= StringVar()

txtTinggi=Entry(window, textvariable=strTxtTinggi)

txtTinggi.place(x=300, y=160, width=70, height=20)

strTxtBMI= StringVar()

txtBMI=Entry(window, textvariable=strTxtBMI)

txtBMI.place(x=300, y=200, width=70, height=20)

strLblMesej=StringVar()

lblMesej= Label(window, textvariable=strLblMesej)

lblMesej.config(font=("Arial", 24))

lblMesej.place(x=180, y=240)

btnkira=Button(window, text="BMI", command=kira_BMI,)

btnkosong=Button(window, text="Kosongkan", command=kosongkan)

btnkeluar=Button(window, text="keluar", command=quit)

btnkira.place(x=100, y=320, width=90, height=40)

btnkosong.place(x=220, y=320, width=90, height=40)

btnkeluar.place(x=340, y=320, width=90, height=40)

#windows

window.title("Mengira BMI Pelajar Sepermai")

window.geometry("600x450") # windows saiz

window.mainloop()
ANTARA MUKA

MENGIRA BMI PELAJAR SEPERMAI

You might also like