Anda di halaman 1dari 4

UJIAN PRAKTIKUM FISIKA KOMPUTASI ( PROGRAM BORLAN DELPHI)

MAHASISWA FISIKA FKIP UNIB TAHUN 2010.

Soal

Buat lah program menghitung Nilai Rata-rata, Standar deviasi, nilai yang besar dan nilai yang
kecil dari input sepuluh data ?

Data pertama 1 Rata-rata


Data kedua 2 Standar deviasi
Data ketiga 3 Nilaai terkecil
Nilai terbesar

HITUNG
HITUNG LAGI
Data ke sepuluh 10 CLOSE

JAWABAN

UNTUK TOMBOL HITUNG

var a, b, c, d, e, f, g, h, i, j : real;

x : real;

Sgm, StandarDeviasi : Real;

Kc : Real;

kb : Real;

begin

a := StrToFloat(Edit1.Text);

b := StrToFloat(Edit2.Text);

c := StrToFloat(Edit3.Text);

d := StrToFloat(Edit4.Text);

e := StrToFloat(Edit5.Text);
f := StrToFloat(Edit6.Text);

g := StrToFloat(Edit7.Text);

h := StrToFloat(Edit8.Text);

i := StrToFloat(Edit9.Text);

j := StrToFloat(Edit10.Text);

//menghitung nilai rata-rata

x := (a+b+c+d+e+f+g+h+i+j)/10;

Label11.Caption := 'Nilai Rata-Ratanya Adalah';

Edit11.Text := FloatToStr(x);

//menghitung standar deviasi

Sgm := 0;

Sgm := sgm+sqr(a-x)+sqr(b-x)+sqr(c-x)+sqr(d-x)+sqr(e-x)+sqr(f-x)+sqr(g-x)+sqr(h-x)+sqr(i-x)
+sqr(j-x);

StandarDeviasi := sqrt(sgm/9);

Label12.Caption := 'Standar Deviasinya Adalah';

Edit12.Text := FloatToStr(StandarDeviasi);

//menghitung nilai terkecil

kc := a;

if b < kc then kc := b

else kc := kc;

if c < kc then kc := c

else kc := kc;

if d < kc then kc := d

else kc := kc;

if e < kc then kc := e
else kc := kc;

if f < kc then kc := f

else kc := kc;

if g < kc then kc := g

else kc := kc;

if h < kc then kc := h

else kc := kc;

if i < kc then kc := i

else kc := kc;

if j < kc then kc := j

else

kc := kc;

Label13.Caption := 'Nilai Terkecil Adalah';

Edit13.Text := FloatToStr(Kc);

//menghitung nilai terbesar

kb := a;

if b > kb then kb := b

else kb := kb;

if c > kb then kb := c

else kb := kb;

if d > kb then kb := d

else kb := kb;

if e > kb then kb := e

else kb := kb ;
if f > kb then kb := f

else kb := kb;

if g >kb then kb := g

else kb := kb;

if h > kb then kb := h

else kb := kb;

if i > kb then kb := i

else kb := kb;

if j > kb then kb := j

else kb := kb;

Label14.Caption := 'Nilai Terbesarnya Adalah';

Edit14.Text := FloatToStr(kb);

form1.color:=cllime;

UNTUK TOMBOL HITUNG LAGI

Edit1.Clear;

Edit2.Clear;

……….

Edit12.Clear;

Edit13.Clear;

Edit14.Clear;

Label11.Caption := '';

Label12.Caption := '';

Label13.Caption := '';

Label14.Caption := '';

form1.color:=clyellow;

Anda mungkin juga menyukai