Rabu, 02 Januari 2013
Program Matriks Dengan Menu Pada Pascal
uses crt;
type t = object
m1, m2 : array [1..2,1..2] of integer;
lok : array [1..4] of integer;
procedure input;
procedure tambah;
procedure kurang;
procedure tampil;
end;
var m : t;
i, j, k, pil : integer;
procedure t.input;
begin
clrscr;
writeln ('input matriks I');
for i := 1 to 2 do
begin
for j := 1 to 2 do
begin
write ('elemen matriks [',i,',',j,']:');
readln (m1 [i,j]);
end;
end;
gotoxy (35,1); writeln('Input Matriks I');
k := 1;
for i := 1 to 2 do
begin
for j := 1 to 2 do
begin
gotoxy (32,k);
inc(k);
write('elemen matriks [',i,',',j,']:');
readln (m2[i,j]);
end;
end;
end;
procedure t.tampil;
begin
gotoxy(8,7) ; writeln ('* MATRIKS 1 *');
gotoxy(8,8) ; writeln (m1[1,1]:5,m1[1,2]:5);
gotoxy(8,9) ; writeln (m1[2,1]:5,m1[2,2]:5);
gotoxy(35,7); writeln ('* MATRIKS II *');
gotoxy(35,8); writeln (m2[1,1]:5,m2[1,2]);
gotoxy(35,9); writeln (m2[2,1]:5,m2[2,2]);
readln;
end;
procedure t.tambah;
begin
gotoxy (21,11); writeln ('Hasil Penjumlahan Matriks');
lok[1] := m1[1,1]+m2[1,1];
lok[2] := m1[1,2]+m2[1,2];
lok[3] := m1[2,1]+m2[2,1];
lok[4] := m1[2,2]+m2[2,2];
gotoxy (21,12); writeln (lok[1]:5,lok[2]:5);
gotoxy (21,13); writeln(lok[3]:5,lok[4]:5);
readln;
end;
procedure t.kurang;
begin
gotoxy (4,9); writeln ('Hasil Pengurangan Matriks I dan II');
lok[1] := m1[1,1]-m2[1,1];
lok[2] := m1[1,2]-m2[1,2];
lok[3] := m1[2,1]-m2[2,1];
lok[4] := m1[2,1]-m2[2,2];
gotoxy (9,11); writeln (lok[1]:5,lok[2]:5);
gotoxy (9,12); writeln (lok[3]:5,lok[4]:5);
readln;
end;
begin
repeat
clrscr;
gotoxy (25,1); writeln ('<<<<____MENU MATRIKS____>>>>');
gotoxy (25,2); writeln ('1. Input Matriks');
gotoxy (25,3); writeln ('2. Penjumlahan Matriks');
gotoxy (25,4); Writeln ('3. Pengurangan Matriks');
gotoxy (25,5); writeln ('4. Keluar');
gotoxy (25,6); writeln ('<<<______________________>>>');
gotoxy (27,7); writeln ('Pilihan [1..4] :'); readln(pil);
case pil of
1 : begin
m.input;
m.tampil;
end;
2 : m.tambah;
3 : m.kurang;
end;
until (pil)=4;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar