!************************************** ! Name: BMI calculator ! Description:For fun ! By: Imaad Abrahams ! ! ! Inputs:None ! ! Returns:None ! !Assumes:None ! !Side Effects:None !************************************** unit BMI_p; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math; type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; EdtWeight: TEdit; EdtHeight: TEdit; EdtBMI: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } Weight : Real; Height : Real; BMI: Real; RoundedBMI : Real; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Weight := StrToFloat(EdtWeight.Text); Height := StrToFloat(EdtHeight.Text); BMI := Weight / (Height * Height); RoundedBMI := RoundTo(BMI, -2); EdtBMI.Text := FloatToStr(RoundedBMI); end; end.