WELCOME TO MY BLOG

Minggu, 13 Mei 2012

Konversi Suhu Menggunakan Delphi 7.0


MEMBUAT PROGRAM KONVERSI SUHU

Untuk membuat program konversi suhu, terdapat beberapa langkah sebagai berikut:
  1. Buatlah form baru kemudian ganti caption menjadi Konversi Suhu, kemudian name diubah menjadi FKonversi.
  2. Simpan dengan cara klik file, kemudian pilih save all (Shift+Ctrl+S), file : Unit1 diubah menjadi UKonversiSuhu.pas, file : Project1 diubah menjadi PKonversiSuhu.dpr, selanjutnya klik tombol OK.
  3. Buatlah desain form konversi suhu seperti gambar 1.1


                            Label1



                                                      LebeledEdit1
                          
                     ComboBox1                                                                 Button1


                   LebeledEdit2

Gambar 1.1 Form Konversi Suhu
  1. Ubahlah properties masing-masing object seperti yang terdapat pada tabel 1.1
Componen Pallete
Object Inspector
Tab
Nama Object
Properties
Keterangan
Standard
Label1
Caption
Konversi Suhu
ComboBox1
Text
Pilihan Konversi

Items
Kelvin to Celcius
Kelvin to Fahrenheit
Kelvin to Rankine
Kelvin to Delisle
Kelvin to Newton
Kelvin to Reamur
Kelvin to Romer
Celcius to Kelvin
Celcius to Fahrenheit
Celcius to Rankine
Celcius to Delisle
Celcius to Newton
Celcius to Reamur
Celcius to Romer
Fahrenheit to Kelvin
Fahrenheit to Celcius
Fahrenheit to Rankine
Fahrenheit to Delisle
Fahrenheit to Newton
Fahrenheit to Reamur
Fahrenheit to Romer
Rankine to Kelvin
Rankine to Celcius
Rankine to Fahrenheit
Rankine to Delisle
Rankine to Newton
Rankine to Reamur
Rankine to Romer
Delisle to Kelvin
Delisle to Celcius
Delisle to Fahrenheit
Delisle to Rankine
Delisle to Newton
Delisle to Reamur
Delisle to Romer
Newton to Kelvin
Newton to Celcius
Newton to Fahrenheit
Newton to Rankine
Newton to Delisle
Newton to Reamur
Newton to Romer
Reamur to Kelvin
Reamur to Celcius
Reamur to Fahrenheit
Reamur to Rankine
Reamur to Delisle
Reamur to Newton
Reamur to Romer
Romer to Kelvin
Romer to Celcius
Romer to Fahrenheit
Romer to Rankine
Romer to Delisle
Romer to Newton
Romer to Reamur

Name
CBKonversi
Button1
Caption
Konversi


Name
BKonversi
Additional
LabeledEdit1
Caption
Masukan Nilai

Name
LEInput
LabeledEdit2
Caption
Hasil Konversi


Name
LEOutput

  1. Pada tombol konversi, masukkan source code konversi suhu berikut:
procedure TFKonversi.BKonversiClick(Sender: TObject);
var a:real;
begin
a:=strtofloat(LEInput.Text);

case CBKonversi.ItemIndex of
      0:LEOutput.Text:=floattostr(a-273.15); //Kelvin to Celcius
      1:LEOutput.Text:=floattostr(a*1.8-459.67); //Kelvin to Fahrenheit
      2:LEOutput.Text:=floattostr(a*1.8); //Kelvin to Rankine
      3:LEOutput.Text:=floattostr((373.15-a)*1.5); //Kelvin to Delisle
      4:LEOutput.Text:=floattostr((a-273.15)*0.33); //Kelvin to Newton
      5:LEOutput.Text:=floattostr((a-273.15)*0.8); //Kelvin to Reamur
      6:LEOutput.Text:=floattostr((a-273.15)*0.525+7.5); //Kelvin to Romer
      7:LEOutput.Text:=floattostr(a+237.15); //Celcius to Kelvin
      8:LEOutput.Text:=floattostr(a*1.8+32); //Celcius to Fahrenheit
      9:LEOutput.Text:=floattostr(a*1.8+491.67); //Celcius to Rankine
      10:LEOutput.Text:=floattostr((100-a)*1.5); //Celcius to Delisle
      11:LEOutput.Text:=floattostr(a-0.33); //Celcius to Newton
      12:LEOutput.Text:=floattostr(a*0.8); //Celcius to Reamur
      13:LEOutput.Text:=floattostr(a*0.525+7.5); //Celcius to Romer
      14:LEOutput.Text:=floattostr((a+459.67)/1.8); //Fahrenheit to Kelvin
      15:LEOutput.Text:=floattostr((a-32)/1.8); //Fahrenheit to Celcius
      16:LEOutput.Text:=floattostr(a+459.67); //Fahrenheit to Rankine
      17:LEOutput.Text:=floattostr((212-a)*0.83); //Fahrenheit to Delisle
      18:LEOutput.Text:=floattostr((a-32)*0.183); //Fahrenheit to Newton
      19:LEOutput.Text:=floattostr((a-32)/2.25); //Fahrenheit to Reamur
      20:LEOutput.Text:=floattostr((a-32)*(7/24)+7.5); //Fahrenheit to Romer
      21:LEOutput.Text:=floattostr(a/1.8); //Rankine to Kelvin
      22:LEOutput.Text:=floattostr(a/1.8+273.15); //Rankine to Celcius
      23:LEOutput.Text:=floattostr(a-459.67); //Rankine to Fahrenheit
      24:LEOutput.Text:=floattostr((671.67-a)*0.83); //Rankine to Delisle
      25:LEOutput.Text:=floattostr((a-491.67)*0.183); //Rankine to Newton
      26:LEOutput.Text:=floattostr((a/1.8+273.15)+0.8); //Rankine to Reamur
      27:LEOutput.Text:=floattostr((a-491.67)*(7/24)+7.5); //Rankine to Romer
      28:LEOutput.Text:=floattostr((373.15-a)*0.67); //Delisle to Kelvin
      29:LEOutput.Text:=floattostr((100-a)*0.67); //Delisle to Celcius
      30:LEOutput.Text:=floattostr((212-a)*1.2); //Delisle to Fahrenheit
      31:LEOutput.Text:=floattostr((671.67-a)*1.2); //Delisle to Rankine
      32:LEOutput.Text:=floattostr((33-a)*0.22); //Delisle to Newton
      33:LEOutput.Text:=floattostr((80-a)*0.53); //Delisle to Reamur
      34:LEOutput.Text:=floattostr((60-a)*0.35); //Delisle to Romer
      35:LEOutput.Text:=floattostr(a*(100/33)+273.15); //Newton to Kelvin
      36:LEOutput.Text:=floattostr(a*(100/33)); //Newton to Celcius
      37:LEOutput.Text:=floattostr(a*5.45+32); //Newton to Fahrenheit
      38:LEOutput.Text:=floattostr(a*5.45+491.67); //Newton to Rankine
      39:LEOutput.Text:=floattostr((33-a)*4.54); //Newton to Delisle
      40:LEOutput.Text:=floattostr(a*2.42); //Newton to Reamur
      41:LEOutput.Text:=floattostr(a*(35/22)+7.5); //Newton to Romer
      42:LEOutput.Text:=floattostr(a/0.8+273.15); //Reamur to Kelvin
      43:LEOutput.Text:=floattostr(a/0.8); //Reamur to Celcius
      44:LEOutput.Text:=floattostr(a*2.25+32); //Reamur to Fahrenheit
      45:LEOutput.Text:=floattostr(a*2.25+491.67); //Reamur to Rankine
      46:LEOutput.Text:=floattostr((80-a)*1.875); //Reamur to Delisle
      47:LEOutput.Text:=floattostr(a*0.4125); //Reamur to Newton
      48:LEOutput.Text:=floattostr(a*(21/32)+7.5); //Reamur to Romer
      49:LEOutput.Text:=floattostr((a-7.5)*(40/21)+273.15); //Romer to Kelvin
      50:LEOutput.Text:=floattostr((a-7.5)*(40/21)); //Romer to Celcius
      51:LEOutput.Text:=floattostr((a-7.5)*(24/7)+32); //Romer to Fahrenheit
      52:LEOutput.Text:=floattostr((a-7.5)*(24/7)+491.67); //Romer to Rankine
      53:LEOutput.Text:=floattostr((60-a)*(20/7)); //Romer to Delisle
      54:LEOutput.Text:=floattostr((a-7.5)*(22/35)); //Romer to Newton
 else
      LEOutput.Text:=floattostr((a-7.5)*(32/21)); //Romer to Reamur    
 end;
end;

  1. Jalankan aplikasi dengan tombol F9.
  2. Masukan nilai, tentukan pilihan konversi misalnya Celcius – Reamur, kemudian klik tombol konversi maka hasil konversi akan muncul secara otomatis.