LISTING
PROGRAM
procedure TForm1.FormCreate(Sender: TObject);
begin
label1.caption :=
'Nama'; //ini komentar
label2.caption :=
'NPM'; //mengubah tampilan kata/kalimat
setelah program di run
label3.caption :=
'UTS';
label4.caption :=
'UAS';
label5.caption :=
'';
label6.caption :=
'';
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
Edit4.Text := '';
button1.caption
:= 'Hitung Hasil';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
uts,uas,hasil :
real;
ipk : char;
begin
label5.caption :=
'Hai ' + edit1.text + ' (' + edit2.text + ')';
uts :=
strtofloat(edit3.text);
uas :=
strtofloat(edit4.text);
hasil := (uts +
uas)/2;
//percabangan IF
if (hasil>85)
and (hasil<=100) then ipk := 'A'
else if
(hasil>70) and (hasil<=85) then ipk := 'B'
else if
(hasil>55) and (hasil<=70) then ipk := 'C'
else if
(hasil>40) and (hasil<=55) then ipk := 'D'
else ipk := 'E';
//sebelum kode
"else", tidak boleh ada tanda titik koma
label6.Caption :=
'Hasil Nilai Anda ' + floattostr(hasil);
label6.caption :=
label6.caption + ' dengan IPK ' + ipk;
end;
end.
Tidak ada komentar:
Posting Komentar