BMI Metric source code in Liberty basics

Body Mass Index Implementation

First Screen


Result Screen



[setup.main.Window]
    '-----Begin code for #main

    WindowWidth = 365
    WindowHeight = 220
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)


    '-----Begin GUI objects code

    statictext #main.statictext1, "Enter Your Name",  15,  52, 102,  20
    TextboxColor$ = "white"
    textbox #main.name, 135,  47, 100,  25
    button #main.button3,"Proceed Now!",[BMI], UL,  15,  92,  95,  25

    '-----End GUI objects code

    open "untitled" for window as #main
    print #main, "font ms_sans_serif 10"

wait
[BMI]

    print #main.name, "!contents? name$"
    m1$ = "Welcome "+name$+" to BMI Calculator"
    notice m1$
    close #main
  '-----Begin code for #1

    WindowWidth = 550
    WindowHeight = 410
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)


    '-----Begin GUI objects code

    statictext #1.statictext1, "You Height",  70,  52,  66,  20 '---- setting position of label
    TextboxColor$ = "white"
    textbox #1.tb1, 150,  47, 100,  25 '---- setting position of height text field
    statictext #1.statictext3, "(in Centimeters)", 150,  82,  92,  20
    statictext #1.statictext4, "Your weight",  70, 117,  69,  20
    textbox #1.tb2, 150, 112, 100,  25
    statictext #1.statictext6, "(in Kilograms)", 150, 147,  81,  20
    button #1.button8,"Compute BMI",[bmi], UL, 150, 177,  90,  25 '---- setting position button
    textbox #1.tb3, 150, 217, 100,  25

    '-----End GUI objects code

    open "Metric BMI" for window as #1 '---- setting the handler
    print #1, "font ms_sans_serif 10"




print #1, "trapclose [quit]"
wait
[bmi]

    print #1.tb1, "!contents? heightInCm$" '------ fetching the values from height text feild and storing result in heightInCm variable
    print #1.tb2, "!contents? weight$"  '------ fetching the valus from weight text field and storing result in heightInCm variable
    heightInMeter = 0.01 * val(heightInCm$) '------ converting the string vales of height txt field into number and measuring it in meters
    square = heightInMeter * heightInMeter '------- taking square of height according to the formula

    totalWeight = val(weight$) '------ converting the string value of weight into number
    result = totalWeight/square '----- applying formula to caculate the Metric BMI
    print #1.tb3, result '------ displaying the result into the text field
    if result<18.5 then notice "You have low BMI"
    if result>18.5 and result<25 then notice "You have normal BMI"
    if result>25 then notice "You have high BMI"
    wait
[quit]
close #main
stop


Get Project Solution Now

Comments