Laman

Selasa, 12 Juni 2012

Codingan Konversi Suhu Pada Delphi

unit KonversiSuhu;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
Button1: TButton;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
procedure FormCreate(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
X:integer ;
Y:integer ;
Cel,Fahr,Rea:Real;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Enabled:=false;
Edit2.Enabled:=false;
Edit3.Enabled:=false;
Edit4.Enabled:=false;
edit2.ReadOnly:=true;
edit3.ReadOnly:=true;
edit4.ReadOnly:=true;

end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
begin
Label1.Caption:='C';
CheckBox2.Enabled:=false;
CheckBox3.Enabled:=false;
Edit1.Enabled:=true;

end
else
begin
Label1.Caption:='';
CheckBox2.Enabled:=true;
CheckBox3.Enabled:=true;
Edit1.Enabled:=false;
end

end;
procedure TForm1.CheckBox2Click(Sender: TObject);
begin
If CheckBox2.Checked then
begin
Label1.Caption:='F';
CheckBox1.Enabled:=false;
CheckBox3.Enabled:=false;
Edit1.Enabled:=true;
end
else
begin
Label1.Caption:='';
CheckBox1.Enabled:=true;
CheckBox3.Enabled:=true;
Edit1.Enabled:=false;
end
end;

procedure TForm1.CheckBox3Click(Sender: TObject);
begin
if CheckBox3.Checked then
begin
Label1.Caption:='R';
CheckBox1.Enabled:=false;
CheckBox2.Enabled:=false;
Edit1.Enabled:=true;
end
else
begin
Label1.Caption:='';
CheckBox1.Enabled:=true;
CheckBox2.Enabled:=true;
Edit1.Enabled:=false;
end
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
Edit2.Enabled:=false;
edit3.Enabled:=false;
edit4.Enabled:=false;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if checkbox1.Checked then
begin
Cel:=strtofloat (edit1.Text);
//rumus Celcius
Cel:= Cel;
//rumus Fahrenheit
Fahr:=(9/5)*Cel+32;
//rumus Reamur
Rea:=(4/5)*Cel;
edit2.Text:=floattostr(Cel);
edit3.Text:=floattostr(Fahr);
edit4.Text:=floattostr(Rea);
edit2.Enabled:=true;
edit3.Enabled:=true;
edit4.Enabled:=true;
end
else
begin
if checkbox2.Checked then
begin
Fahr:=strtofloat(edit1.Text);
//rumus fahrenheit
Fahr:= Fahr;
//rumus celcius
Cel:=5/9*(Fahr-32);
//rumus reamur
Rea:=4/9*(Fahr-32);
edit2.Text:=floattostr(Cel);
edit3.Text:=floattostr(Fahr);
edit4.Text:=floattostr(Rea);
edit2.Enabled:=true;
edit3.Enabled:=true;
edit4.Enabled:=true;
end
else
begin

if checkbox3.Checked then
begin
Rea:=strtofloat (edit1.Text);
//rumus reamur
rea:=rea;
//rumus celcius
cel:=(5/4)*Rea;
//rumus Fahr
Fahr:=(9/4)*Rea+32;
edit2.Text:=floattostr(Cel);
edit3.Text:=floattostr(Fahr);
edit4.Text:=floattostr(Rea);
edit2.Enabled:=true;
edit3.Enabled:=true;
edit4.Enabled:=true;
end
end;
end;
end;
end.

2 komentar:

  1. Balasan
    1. masih dalam proses gan, datanya hilang kemaren... untung masih nemu codingannya....

      Hapus