listing program matematika lingga 09512037

39
LISTING PROGRAM MATEMATIKA Program Delphi Disusun untuk memenuhi tugas akhir mata kuliah Program Komputer Dosen Pembimbing: Deddy Sofyan, M.Pd. Oleh : Lingga Peristian Selamet 09512037 Kelas 2 C Jurusan Pendidikan Matematika

Upload: teguh-panji

Post on 27-Nov-2014

113 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Listing Program Matematika Lingga 09512037

LISTING PROGRAM MATEMATIKAProgram Delphi

Disusun untuk memenuhi tugas akhir mata kuliah Program Komputer

Dosen Pembimbing: Deddy Sofyan, M.Pd.

Oleh :Lingga Peristian Selamet

09512037Kelas 2 C

Jurusan Pendidikan MatematikaSekolah Tinggi Keguruan dan Ilmu Pendidikan

(STKIP) GARUTJuli 2011

Page 2: Listing Program Matematika Lingga 09512037

PROGRAM MATEMATIKA

1. Program MenuProgram Sebelum di Run

Program Setelah di Run

Listing Programvar FormMenu: TFormMenu; a,s:integer;implementation

usesU_LINGKARAN, U_TRAPESIUM, U_SEGIEMPAT, U_SEGITIGA, U_KALKULATOR, U_KALKULATOR2, U_DATAMAHASISWA, U_Kuadrat, U_Aritmatika, U_Geometri;

{$R *.dfm}

procedure TFormMenu.Aritmatika1Click(Sender: TObject);beginformaritmatika.show;formmenu.Hide;end;

Page 3: Listing Program Matematika Lingga 09512037

procedure TFormMenu.Biasa1Click(Sender: TObject);beginformkalkulator2.show;formmenu.Hide;end;

procedure TFormMenu.Datamahasiswa1Click(Sender: TObject);beginformdata.show;formmenu.Hide;end;

procedure TFormMenu.DeretAritmatika1Click(Sender: TObject);beginformaritmatika.Show;formmenu.Hide;end;

procedure TFormMenu.DeretGeometri1Click(Sender: TObject);beginformgeometri.Show;formmenu.Hide;end;

procedure TFormMenu.Exit2Click(Sender: TObject);beginapplication.Terminate;end;

procedure TFormMenu.Geometri1Click(Sender: TObject);beginformgeometri.show;formmenu.Hide;end;

procedure TFormMenu.KalkulatorSainsClick(Sender: TObject);beginformkalkulator.Show;formmenu.Hide;end;

procedure TFormMenu.Lingkatan1Click(Sender: TObject);beginformlingkaran.show;formmenu.Hide;

Page 4: Listing Program Matematika Lingga 09512037

end;

procedure TFormMenu.PersamaanKuadrat1Click(Sender: TObject);beginformkuadrat.show;formmenu.Hide;end;

procedure TFormMenu.rapesium1Click(Sender: TObject);beginformtrapesium.show;formmenu.Hide;end;

procedure TFormMenu.Sains1Click(Sender: TObject);beginformkalkulator.show;formmenu.Hide;end;

procedure TFormMenu.SegiEmpat1Click(Sender: TObject);beginformsegiempat.show;formmenu.Hide;end;

procedure TFormMenu.SegiTiga1Click(Sender: TObject);beginformsegitiga.show;formmenu.Hide;end;

procedure TFormMenu.Timer1Timer(Sender: TObject);begina:=a+1; if a mod 4 =0 then begin label1.Caption:=''; label2.Caption:=''; label4.Caption:='LINGGA PERISTIAN SELAMET (09512037)'; label7.Caption:='Sekolah Tinggi Keguruan Dan Ilmu Pendidikan (STKIP)'; label8.Caption:=''; end else if a mod 4 =1 then begin

Page 5: Listing Program Matematika Lingga 09512037

label1.Caption:='PROGRAM MATEMATIKA KELOMPOK'; label2.Caption:=''; label4.Caption:=''; label7.Caption:='Sekolah Tinggi Keguruan Dan Ilmu Pendidikan (STKIP)'; label8.Caption:='2011'; end else if a mod 4 =2 then begin label1.Caption:=''; label2.Caption:=''; label4.Caption:=''; label7.Caption:='Sekolah Tinggi Keguruan Dan Ilmu Pendidikan (STKIP)'; label8.Caption:=''; end else if a mod 4 =3 then begin label1.Caption:='PROGRAM MATEMATIKA KELOMPOK'; label2.Caption:='Disusun Oleh :'; label4.Caption:=''; label7.Caption:=''; label8.Caption:='2011'; end end;

procedure TFormMenu.Timer3Timer(Sender: TObject);beginlabel11.Caption:=datetostr(now);label12.Caption:=timetostr(now);end;

end.

Page 6: Listing Program Matematika Lingga 09512037

2. Bangun Datara. Segiempat

Program Sebelum di Run

Program Setelah di Run

Listing Programvar Formsegiempat: TFormsegiempat; a,kel,luas:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormsegiempat.Button1Click(Sender: TObject);begina:=strtofloat(edit1.Text);kel:=4*a;luas:=a*A;edit3.Text:=floattostr(kel);edit4.Text:=floattostr(luas);end;

procedure TFormsegiempat.Button2Click(Sender: TObject);beginedit1.Clear;edit3.Clear;edit4.Clear;end;

procedure TFormsegiempat.Button3Click(Sender: TObject);beginformmenu.show;formsegiempat.Hide;end;end.

Page 7: Listing Program Matematika Lingga 09512037

b. SegitigaProgram Sebelum di Run

Program Setelah di Run

Listing Programvar Formsegitiga: TFormsegitiga; a,t,l:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormsegitiga.Button1Click(Sender: TObject);begina:=strtofloat(edit1.Text);t:=strtofloat(edit2.Text);l:=(A*t)/2;edit3.Text:=floattostr(l);end;

procedure TFormsegitiga.Button2Click(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;end;

procedure TFormsegitiga.Button3Click(Sender: TObject);beginformmenu.show;formsegitiga.Hide;end;end.

Page 8: Listing Program Matematika Lingga 09512037

c. TrapesiumProgram Sebelum di Run

Program Setelah di Run

Listing Programvar FormTrapesium: TFormTrapesium; a,b,t,l:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormTrapesium.Button1Click(Sender: TObject);begina:=strtofloat(edit1.Text);b:=strtofloat(edit2.Text);t:=strtofloat(edit3.Text);l:=((a+b)/2)*t;edit4.Text:=floattostr(l);end;

procedure TFormTrapesium.Button2Click(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;edit4.Clear;end;

procedure TFormTrapesium.Button3Click(Sender: TObject);beginformmenu.show;formtrapesium.Hide;end;end.

Page 9: Listing Program Matematika Lingga 09512037

d. LingkaranProgram Sebelum di Run

Program Setelah di Run

Listing Programvar FormLingkaran: TFormLingkaran; r,keliling,luas:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormLingkaran.Button1Click(Sender: TObject);beginr:=strtofloat(edit1.Text);keliling:=2*pi*r;luas:=pi*r*r;edit2.Text:=floattostr(keliling);edit3.Text:=floattostr(luas);end;

procedure TFormLingkaran.Button2Click(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;end;

procedure TFormLingkaran.Button3Click(Sender: TObject);beginformmenu.show;formlingkaran.Hide;end;end.

Page 10: Listing Program Matematika Lingga 09512037

3. Kalkulator IlmiahProgram Sebelum di Run

Program Setelah di Run

Listing Programvar FormKALKULATOR: TFormKALKULATOR; MemAngka, MemOperator, MemLogic, MemSimpan:string;implementationuses U_MENU;

{$R *.dfm}procedure TFormKALKULATOR.BitBtn1Click(Sender: TObject);beginformmenu.show;formkalkulator.Hide;end;

procedure TFormKALKULATOR.Button10Click(Sender: TObject); {0}beginif edit1.text<>'' thenif MemLogic='0' then begin if MemOperator<>'' then edit1.Text:='0' else if edit1.text='0' then edit1.text:='0' else begin

Page 11: Listing Program Matematika Lingga 09512037

edit1.Text:=edit1.Text+'0'; MemLogic:='1'; end; endelse edit1.Text:=edit1.Text+'0';end;

procedure TFormKALKULATOR.Button11Click(Sender: TObject); {.}beginif edit1.text<>'' thenedit1.Text:=edit1.Text + '.';end;

procedure TFormKALKULATOR.Button12Click(Sender: TObject); {+/-}beginif edit1.text<>'' thenedit1.Text:=floattostr(strtofloat(edit1.Text)*(-1));end;

procedure TFormKALKULATOR.Button13Click(Sender: TObject);beginif (edit1.text<>'') then if MemLogic='0' then MemOperator:='+' else if (MemOperator='') then begin MemOperator:='+'; MemLogic:='0'; MemAngka:=edit1.Text; end else begin if MemOperator='+' then edit1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(edit1.Text)); if MemOperator='-' then edit1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(edit1.Text)); if MemOperator='x' then edit1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(edit1.Text)); if MemOperator='/' then edit1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(edit1.Text)); if MemOperator='^' then edit1.Text:=floattostr(exp(strtofloat(edit1.Text)*ln(strtofloat(MemAngka)))); MemAngka:=edit1.Text; MemOperator:='+'; MemLogic:='0'; end;end;

procedure TFormKALKULATOR.Button14Click(Sender: TObject);begin

Page 12: Listing Program Matematika Lingga 09512037

if (edit1.text<>'') then if MemLogic='0' then MemOperator:='-' else if (MemOperator='') then begin MemOperator:='-'; MemLogic:='0'; MemAngka:=edit1.Text; end else begin if MemOperator='+' then edit1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(edit1.Text)); if MemOperator='-' then edit1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(edit1.Text)); if MemOperator='x' then edit1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(edit1.Text)); if MemOperator='/' then edit1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(edit1.Text)); if MemOperator='^' then edit1.Text:=floattostr(exp(strtofloat(edit1.Text)*ln(strtofloat(MemAngka)))); MemAngka:=edit1.Text; MemOperator:='-'; MemLogic:='0'; end;end;

procedure TFormKALKULATOR.Button15Click(Sender: TObject);beginif (edit1.text<>'') then if MemLogic='0' then MemOperator:='x' else if (MemOperator='') then begin MemOperator:='x'; MemLogic:='0'; MemAngka:=edit1.Text; end else begin if MemOperator='+' then edit1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(edit1.Text)); if MemOperator='-' then edit1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(edit1.Text)); if MemOperator='x' then edit1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(edit1.Text)); if MemOperator='/' then edit1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(edit1.Text)); if MemOperator='^' then edit1.Text:=floattostr(exp(strtofloat(edit1.Text)*ln(strtofloat(MemAngka)))); MemAngka:=edit1.Text; MemOperator:='x'; MemLogic:='0'; end;end;

Page 13: Listing Program Matematika Lingga 09512037

procedure TFormKALKULATOR.Button16Click(Sender: TObject);beginif (edit1.text<>'') then if MemLogic='0' then MemOperator:='/' else if (MemOperator='') then begin MemOperator:='/'; MemLogic:='0'; MemAngka:=edit1.Text; end else begin if MemOperator='+' then edit1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(edit1.Text)); if MemOperator='-' then edit1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(edit1.Text)); if MemOperator='x' then edit1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(edit1.Text)); if MemOperator='/' then edit1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(edit1.Text)); if MemOperator='^' then edit1.Text:=floattostr(exp(strtofloat(edit1.Text)*ln(strtofloat(MemAngka)))); MemAngka:=edit1.Text; MemOperator:='/'; MemLogic:='0'; end;end;

procedure TFormKALKULATOR.Button17Click(Sender: TObject);beginif edit1.text<>'' then edit1.Text:=floattostr(sqrt(strtofloat(edit1.Text)));end;

procedure TFormKALKULATOR.Button18Click(Sender: TObject);beginif edit1.text<>'' then edit1.Text:=floattostr(sqr(strtofloat(edit1.Text)));end;

procedure TFormKALKULATOR.Button19Click(Sender: TObject);begin if (edit1.text<>'') then if MemLogic='0' then MemOperator:='^' else if (MemOperator='') then begin MemOperator:='^'; MemLogic:='0'; MemAngka:=edit1.Text; end

Page 14: Listing Program Matematika Lingga 09512037

else begin if MemOperator='+' then edit1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(edit1.Text)); if MemOperator='-' then edit1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(edit1.Text)); if MemOperator='x' then edit1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(edit1.Text)); if MemOperator='/' then edit1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(edit1.Text)); if MemOperator='^' then edit1.Text:=floattostr(exp(strtofloat(edit1.Text)*ln(strtofloat(MemAngka)))); MemAngka:=edit1.Text; MemOperator:='^'; MemLogic:='0'; end;end;

procedure TFormKALKULATOR.Button1Click(Sender: TObject); {1}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='1' else edit1.text:='1'; endelse edit1.Text:=edit1.Text+'1';end;

procedure TFormKALKULATOR.Button20Click(Sender: TObject);begin if edit1.Text = '0' then edit1.Text:='Error,, eh bodo, ga Boleh 0 tau' else if edit1.Text<>'' then edit1.Text :=floattostr(1/strtofloat(edit1.Text)); MemLogic :='0';end;

procedure TFormKALKULATOR.Button21Click(Sender: TObject);beginif edit1.Text<>'' then edit1.Text := floattostr(pi);end;

procedure TFormKALKULATOR.Button22Click(Sender: TObject);var sudut:real;beginif edit1.Text<>'' then begin sudut:=strtofloat(edit1.Text); if Radiobutton1.Checked = true then sudut:=sudut*pi/180 else

Page 15: Listing Program Matematika Lingga 09512037

if Radiobutton2.Checked = true then sudut:=sudut else if radiobutton3.Checked = true then sudut:=sudut*pi/200; edit1.Text := floattostr(sin(sudut)); MemLogic :='0'; end;end;

procedure TFormKALKULATOR.Button23Click(Sender: TObject);var sudut:real;beginif edit1.Text<>'' then begin sudut:=strtofloat(edit1.Text); if Radiobutton1.Checked = true then sudut:=sudut*pi/180 else if Radiobutton2.Checked = true then sudut:=sudut else if radiobutton3.Checked = true then sudut:=sudut*pi/200; edit1.Text := floattostr(cos(sudut)); MemLogic :='0'; end;end;

procedure TFormKALKULATOR.Button24Click(Sender: TObject);var sudut,a,b:real;beginif edit1.Text<>'' then begin sudut:=strtofloat(edit1.Text); if Radiobutton1.Checked = true then sudut:=sudut*pi/180 else if Radiobutton2.Checked = true then sudut:=sudut else if radiobutton3.Checked = true then sudut:=sudut*pi/200; a:=sin(sudut); b:=cos(sudut); edit1.Text := floattostr(a/b); MemLogic :='0'; end;end;

procedure TFormKALKULATOR.Button25Click(Sender: TObject);begin if (edit1.text<>'') then edit1.Text := floattostr(ln(strtofloat(edit1.Text)));end;

procedure TFormKALKULATOR.Button26Click(Sender: TObject);begin if edit1.Text<=inttostr(0) then edit1.Text :='Error'

Page 16: Listing Program Matematika Lingga 09512037

else if (edit1.text<>'') then edit1.Text := floattostr(ln(10)/ln(strtofloat(edit1.Text)));end;

procedure TFormKALKULATOR.Button27Click(Sender: TObject);var i,n,fak:integer;beginif edit1.Text<>'' then begin n :=strtoint(edit1.Text); fak:=1; for i:=1 to n do fak:=fak*i;

edit1.Text:=inttostr(fak); MemLogic :='0'; end;end;

procedure TFormKALKULATOR.Button28Click(Sender: TObject);begin edit1.Text := MemSimpan ;end;

procedure TFormKALKULATOR.Button29Click(Sender: TObject);begin MemSimpan := edit1.Text ; MemLogic := '0'; MemOperator :=''; MemAngka := '0';end;

procedure TFormKALKULATOR.Button2Click(Sender: TObject); {2}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='2' else edit1.text:='2'; endelse edit1.Text:=edit1.Text+'2';end;

Page 17: Listing Program Matematika Lingga 09512037

procedure TFormKALKULATOR.Button30Click(Sender: TObject);beginMemSimpan:='0';end;

procedure TFormKALKULATOR.Button31Click(Sender: TObject);beginif MemOperator='+' then edit1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(edit1.Text)); if MemOperator='-' then edit1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(edit1.Text)); if MemOperator='x' then edit1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(edit1.Text)); if MemOperator='/' then edit1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(edit1.Text)); if MemOperator='^' then edit1.Text:=floattostr(exp(strtofloat(edit1.Text)*ln(strtofloat(MemAngka)))); MemAngka:=edit1.Text; MemLogic:='0';end;

procedure TFormKALKULATOR.Button32Click(Sender: TObject);beginedit1.clear;MemLogic:='';MemSimpan:='0';Radiobutton1.enabled:=false;Radiobutton2.enabled:=false;Radiobutton3.enabled:=false;button1.Enabled:=false;button2.Enabled:=false;button3.Enabled:=false;button4.Enabled:=false;button5.Enabled:=false;button6.Enabled:=false;button7.Enabled:=false;button8.Enabled:=false;button9.Enabled:=false;button10.Enabled:=false;button11.Enabled:=false;button12.Enabled:=false;button13.Enabled:=false;button14.Enabled:=false;button15.Enabled:=false;button16.Enabled:=false;button17.Enabled:=false;button18.Enabled:=false;button19.Enabled:=false;button20.Enabled:=false;button21.Enabled:=false;

Page 18: Listing Program Matematika Lingga 09512037

button22.Enabled:=false;button23.Enabled:=false;button24.Enabled:=false;button25.Enabled:=false;button26.Enabled:=false;button27.Enabled:=false;button28.Enabled:=false;button29.Enabled:=false;button30.Enabled:=false;button31.Enabled:=false;button32.Enabled:=false;end;

procedure TFormKALKULATOR.Button33Click(Sender: TObject);beginedit1.Text:='0';MemLogic:='0';MemOperator:='';MemAngka:='0';radiobutton1.enabled:=true;radiobutton2.enabled:=true;radiobutton3.enabled:=true;button1.Enabled:=true;button2.Enabled:=true;button3.Enabled:=true;button4.Enabled:=true;button5.Enabled:=true;button6.Enabled:=true;button7.Enabled:=true;button8.Enabled:=true;button9.Enabled:=true;button10.Enabled:=true;button11.Enabled:=true;button12.Enabled:=true;button13.Enabled:=true;button14.Enabled:=true;button15.Enabled:=true;button16.Enabled:=true;button17.Enabled:=true;button18.Enabled:=true;button19.Enabled:=true;button20.Enabled:=true;button21.Enabled:=true;button22.Enabled:=true;button23.Enabled:=true;button24.Enabled:=true;

Page 19: Listing Program Matematika Lingga 09512037

button25.Enabled:=true;button26.Enabled:=true;button27.Enabled:=true;button28.Enabled:=true;button29.Enabled:=true;button30.Enabled:=true;button31.Enabled:=true;button32.Enabled:=true;radiobutton1.Checked:=true;end;

procedure TFormKALKULATOR.Button34Click(Sender: TObject);beginformmenu.Show;formkalkulator.Hide;end;

procedure TFormKALKULATOR.Button3Click(Sender: TObject); {3}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='3' else edit1.text:='3'; endelse edit1.Text:=edit1.Text+'3';end;

procedure TFormKALKULATOR.Button4Click(Sender: TObject); {4}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='4' else edit1.text:='4'; endelse edit1.Text:=edit1.Text+'4';end;

procedure TFormKALKULATOR.Button5Click(Sender: TObject); {5}beginif edit1.text<>'' then

Page 20: Listing Program Matematika Lingga 09512037

if MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='5' else edit1.text:='5'; endelse edit1.Text:=edit1.Text+'5';end;

procedure TFormKALKULATOR.Button6Click(Sender: TObject); {6}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='6' else edit1.text:='6'; endelse edit1.Text:=edit1.Text+'6';end;

procedure TFormKALKULATOR.Button7Click(Sender: TObject); {7}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='7' else edit1.text:='7'; endelse edit1.Text:=edit1.Text+'7';end;

procedure TFormKALKULATOR.Button8Click(Sender: TObject); {8}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='8' else edit1.text:='8'; endelse

Page 21: Listing Program Matematika Lingga 09512037

edit1.Text:=edit1.Text+'8';end;

procedure TFormKALKULATOR.Button9Click(Sender: TObject); {9}beginif edit1.text<>'' thenif MemLogic='0' then begin MemLogic:='1'; if MemOperator<>'' then edit1.Text:='9' else edit1.text:='9'; endelse edit1.Text:=edit1.Text+'9';end;

procedure TFormKALKULATOR.formcreate(Sender: TObject);beginedit1.Clear;radiobutton1.enabled:=false;radiobutton2.enabled:=false;radiobutton3.enabled:=false;button1.Enabled:=false;button2.Enabled:=false;button3.Enabled:=false;button4.Enabled:=false;button5.Enabled:=false;button6.Enabled:=false;button7.Enabled:=false;button8.Enabled:=false;button9.Enabled:=false;button10.Enabled:=false;button11.Enabled:=false;button12.Enabled:=false;button13.Enabled:=false;button14.Enabled:=false;button15.Enabled:=false;button16.Enabled:=false;button17.Enabled:=false;button18.Enabled:=false;button19.Enabled:=false;button20.Enabled:=false;button21.Enabled:=false;button22.Enabled:=false;button23.Enabled:=false;button24.Enabled:=false;

Page 22: Listing Program Matematika Lingga 09512037

button25.Enabled:=false;button26.Enabled:=false;button27.Enabled:=false;button28.Enabled:=false;button29.Enabled:=false;button30.Enabled:=false;button31.Enabled:=false;button32.Enabled:=false;end;end.

Page 23: Listing Program Matematika Lingga 09512037

4. Input dan Output dataProgram Sebelum di Run

Program Setelah di Run

Listing Programvar FormData: TFormData; a,p:integer; Nama,NIM,Kelas,no:array[1..10] of string;implementationuses U_MENU;{$R *.dfm}

procedure TFormData.Button1Click(Sender: TObject);beginif a<=10 then No[a]:=(edit1.Text); Nama[a]:=(edit2.Text); NIM[a]:=(edit3.Text); Kelas[a]:=(edit4.Text);

Page 24: Listing Program Matematika Lingga 09512037

edit2.SetFocus; listbox1.Items.Add('No : '+(inttostr(a))); listbox1.Items.Add('Nama : '+(nama[a])); listbox1.Items.Add('NIM : '+(nim[a])); listbox1.Items.Add('Kelas : '+(kelas[a])); listbox1.Items.Add('----------------------------');Stringgrid1.Cells[0,0]:='No';Stringgrid1.Cells[1,0]:='Nama';Stringgrid1.Cells[2,0]:='NIM';Stringgrid1.Cells[3,0]:='Kelas';for a := strtoint(edit1.Text) to a do begin Stringgrid1.Cells[0,a]:=inttostr(a); Stringgrid1.Cells[1,a]:=Nama[a]; Stringgrid1.Cells[2,a]:=NIM[a]; Stringgrid1.Cells[3,a]:=Kelas[a];if a<10 then Begin edit1.Text:=inttostr(a); Endelseif a=10 then messagedlg('Tos atuh tong teterusan, CAPE Ngetik',mtinformation,[mbyes],0); end;end;

procedure TFormData.Button2Click(Sender: TObject);beginformdata.Hide;formmenu.show;end;

procedure TFormData.FormCreate(Sender: TObject);begina:=1;edit1.Text:=inttostr(a);Stringgrid1.Cells[0,0]:='No';Stringgrid1.Cells[1,0]:='Nama';Stringgrid1.Cells[2,0]:='NIM';Stringgrid1.Cells[3,0]:='Kelas';end;end.

Page 25: Listing Program Matematika Lingga 09512037

5. Persamaan KuadratProgram Sebelum di Run

Program Setelah di Run

Listing Programvar Formkuadrat: TFormkuadrat; a,b,c,d,e,x1,x2:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormkuadrat.Button2Click(Sender: TObject);begina:=strtofloat(edit1.text);b:=strtofloat(edit2.text);c:=strtofloat(edit3.text);d:=(b*b)-(4*a*c);panel4.Caption:=floattostr(d);if d=0 then begin x1:=(-b)/(2*a); x2:=(-b)/(2*a); panel5.Caption:=floattostr(x1); panel6.Caption:=floattostr(x2); e:=(x1*x1)+(x2*x2); panel7.Caption:=floattostr(e); endelse if d>0 then begin x1:=(-b+sqrt(d))/(2*a); x2:=(-b-sqrt(d))/(2*a); panel5.Caption:=floattostr(x1); panel6.Caption:=floattostr(x2); e:=(x1*x1)+(x2*x2); panel7.Caption:=floattostr(e);

Page 26: Listing Program Matematika Lingga 09512037

endelse begin x1:=(-b)/(2*a); x2:=sqrt(-d)/(2*a); panel5.Caption:=floattostr(x1)+' + '+floattostr(x2)+'i'; panel6.Caption:=floattostr(x1)+' - '+floattostr(x2)+'i'; e:=(x1*x1)+(x2*x2); panel7.Caption:=floattostr(e); end;end;

procedure TFormkuadrat.Button3Click(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;panel4.Caption:='';panel5.Caption:='';panel6.Caption:='';panel7.Caption:='';end;

procedure TFormkuadrat.Button4Click(Sender: TObject);beginformmenu.show;formkuadrat.Hide;end;end.

Page 27: Listing Program Matematika Lingga 09512037

6. Deret AritmatikaProgram Sebelum di Run

Program Setelah di Run

Listing Programvar Formaritmatika: TFormaritmatika; i,n:integer; a,b,m,un,sn:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormaritmatika.Button1Click(Sender: TObject);begina:=strtofloat(edit1.Text);b:=strtofloat(edit2.Text);n:=strtoint(edit3.Text);un:=a+((n-1)*b);sn:=(1/2)*n*(a+un);m:=-1;listbox1.items.Add('tampilan Hasil Perhitungan Jumlah Deret Aritmatika');for i := 1 to n do begin m:=m+b; listbox1.Items.Add('Nilai Suku Ke '+inttostr(i)+' atau U'+inttostr(i)+

Page 28: Listing Program Matematika Lingga 09512037

' = '+floattostr(m)); end; listbox1.Items.Add('Nilai Suku Pertama atau a = '+floattostr(a)); listbox1.Items.Add('Nilai Beda Bilangan atau b = '+floattostr(b)); listbox1.Items.Add('Jumlah deret Aritmatika '+inttostr(n)+' Suku Pertama = '+ floattostr(sn));end;

procedure TFormaritmatika.Button2Click(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;listbox1.Clear;end;

procedure TFormaritmatika.Button3Click(Sender: TObject);beginformmenu.show;formaritmatika.Hide;end;end.

Page 29: Listing Program Matematika Lingga 09512037

7. Deret GeometriProgram Sebelum di Run

Program Setelah di Run

Listing Programvar FormGeometri: TFormGeometri; i,a,r,n:integer; p,un,sn:real;implementationuses U_MENU;{$R *.dfm}

procedure TFormGeometri.Button1Click(Sender: TObject);begina:=strtoint(edit1.Text);r:=strtoint(edit2.Text);n:=strtoint(edit3.Text);listbox1.Items.Add('Hasil Perhitungan Jumlah Deret Geometri');listbox1.Items.Add('----------------------------------------');p:=-1;for i := 1 to n do begin p:=p+1; un:=a*(exp(p*ln(r)));

Page 30: Listing Program Matematika Lingga 09512037

listbox1.Items.Add('Nilai Suku Ke '+inttostr(i)+' = '+floattostr(un)); end;listbox1.Items.Add('Nilai Suku Pertama atau a ='+inttostr(a));listbox1.Items.Add('Perbandingan Bilangan atau r ='+inttostr(r));sn:=(a*(exp(n*ln(r))-1))/(r-1);listbox1.Items.Add('Jumlah Deret Geometri '+inttostr(n)+' Suku Pertama = '+floattostr(sn));end;

procedure TFormGeometri.Button2Click(Sender: TObject);beginedit1.Clear;edit2.Clear;edit3.Clear;listbox1.Clear;end;

procedure TFormGeometri.Button3Click(Sender: TObject);beginformmenu.show;formgeometri.Hide;end;end.