Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Nama : Toriq sudrajat

NPM : 5520117111
Tugas Pemrograman Destop “Array”
unit ArrayToriqs;

interface

uses

Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,


Vcl.Graphics,

Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;

type

TForm_OPMatrik = class(TForm)

Label1: TLabel;

GroupBox2: TGroupBox;

GroupBox3: TGroupBox;

GroupBox4: TGroupBox;

GroupBox1: TGroupBox;

Label2: TLabel;

Label3: TLabel;

GroupBox5: TGroupBox;

txt_BrsM_A: TEdit;

Txt_Klm_A: TEdit;

cmd_BuatMatrik: TButton;

cmd_keluar: TButton;

CMD_Jumlah: TButton;

cmd_Kali: TButton;

Cmd_Kurang: TButton;

StringGrid1: TStringGrid;

StringGrid2: TStringGrid;

StringGrid3: TStringGrid;

procedure CMD_JumlahClick(Sender: TObject);

procedure Cmd_KurangClick(Sender: TObject);


procedure cmd_KaliClick(Sender: TObject);

procedure cmd_BuatMatrikClick(Sender: TObject);

procedure cek_Kolom;

procedure bersih;

procedure cmd_keluarClick(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form_OPMatrik: TForm_OPMatrik;

implementation

{$R *.dfm}

procedure TForm_OPMatrik.cmd_BuatMatrikClick(Sender: TObject);

var kol,brs:integer;

begin

cek_Kolom; //Panggil Prosedure

brs:=StrToIntDef(txt_BrsM_A.Text,0);

kol:=StrToIntDef(Txt_Klm_A.Text,0);

StringGrid1.RowCount:=brs+1;

StringGrid1.ColCount:=kol+1;

StringGrid2.RowCount:=brs+1;

StringGrid2.ColCount:=kol+1;

StringGrid3.RowCount:=brs+1;

StringGrid3.ColCount:=kol+1;

bersih; //Panggil Prosedure

end;
procedure TForm_OPMatrik.cek_Kolom;

begin

if ((Strtoint(txt_BrsM_A.Text)>5)) or (StrToInt(Txt_Klm_A.Text)>5) then

begin

txt_BrsM_A.SetFocus;

txt_BrsM_A.Text:='';

Txt_Klm_A.Text:='';

txt_BrsM_A.Text:='5';

Txt_Klm_A.Text:='5';

end;

end;

procedure TForm_OPMatrik.bersih;

var i,j:integer;

begin

for i := 1 to StrToInt(txt_BrsM_A.Text) do

begin

for j := 1 to StrToInt(Txt_Klm_A.Text) do

begin

stringgrid1.Cells[j,i] := '0';

stringgrid2.Cells[j,i] := '0';

stringgrid3.Cells[j,i] := '0';

end;

end;

end;

procedure TForm_OPMatrik.CMD_JumlahClick(Sender: TObject);

var
i,j,b,k : integer;

MatrikA:array[1..10,1..10] of integer;

MatrikB:array[1..10,1..10] of integer;

hasil:array[1..10,1..10] of integer;

begin

b:=StrToInt(txt_BrsM_A.Text);

k:=StrToInt(Txt_Klm_A.Text);

for i := 1 to b do

begin

for j := 1 to k do

begin

MatrikA[i,j]:=StrToInt(StringGrid1.Cells[j,i]);

MatrikB[i,j]:=StrToInt(StringGrid2.Cells[j,i]);

hasil[i,j]:= MatrikA[i,j]+ MatrikB[i,j];

StringGrid3.Cells[i,j] := inttostr(Hasil[i,j]);

end;

end;

end;

procedure TForm_OPMatrik.cmd_KaliClick(Sender: TObject);

var

i,j,b,k : integer;

MatrikA:array[1..10,1..10] of integer;

MatrikB:array[1..10,1..10] of integer;

hasil:array[1..10,1..10] of integer;

begin

b:=StrToInt(txt_BrsM_A.Text);

k:=StrToInt(Txt_Klm_A.Text);

for i := 1 to b do
begin

for j := 1 to k do

begin

MatrikA[i,j]:=StrToInt(StringGrid1.Cells[j,i]);

MatrikB[i,j]:=StrToInt(StringGrid2.Cells[j,i]);

hasil[i,j]:= MatrikA[i,j]- MatrikB[i,j];

StringGrid3.Cells[i,j] := inttostr(Hasil[i,j]);

end;

end;

end;

procedure TForm_OPMatrik.cmd_keluarClick(Sender: TObject);

begin

Application.Terminate;

end;

procedure TForm_OPMatrik.cmd_KurangClick(Sender: TObject);

var

i,j,b,k : integer;

MatrikA:array[1..10,1..10] of integer;

MatrikB:array[1..10,1..10] of integer;

hasil:array[1..10,1..10] of integer;

begin

b:=StrToInt(txt_BrsM_A.Text);

k:=StrToInt(Txt_Klm_A.Text);

for i := 1 to b do

begin

for j := 1 to k do

begin
MatrikA[i,j]:=StrToInt(StringGrid1.Cells[j,i]);

MatrikB[i,j]:=StrToInt(StringGrid2.Cells[j,i]);

hasil[i,j]:= MatrikA[i,j]* MatrikB[i,j];

StringGrid3.Cells[i,j] := inttostr(Hasil[i,j]);

end;

end;

end;

end.

You might also like