Tugas 4
1. Listing Program
unit tugas1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ForToDo: TButton;
ForDowntoDo: TButton;
WhileDo: TButton;
RepeatUntil: TButton;
bt_pangkat: TButton;
btKeluar: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
bil: TLabel;
Pangkat: TLabel;
hasil: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Binput: TButton;
procedure btKeluarClick(Sender: TObject);
procedure ForToDoClick(Sender: TObject);
procedure ForDowntoDoClick(Sender: TObject);
procedure WhileDoClick(Sender: TObject);
procedure RepeatUntilClick(Sender: TObject);
procedure bt_pangkatClick(Sender: TObject);
procedure BinputClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btKeluarClick(Sender: TObject);
begin
close;
end;
procedure TForm1.ForToDoClick(Sender: TObject);
var
i,j:integer;b:string;
begin
b:='';j:=2;
for i:=1 to 10 do
begin
b:=b+inttostr(i)+'';
j:=j+2;
end;
label1.Caption:=b;
end;
procedure TForm1.ForDowntoDoClick(Sender: TObject);
var
i,j:integer;b:string;
begin
b:='';j:=2;
for i:=10 downto 1 do
begin
b:=b+inttostr(i)+'';
j:=j+2;
end;
label2.caption:=b;
end;
procedure TForm1.WhileDoClick(Sender: TObject);
var
i,j:integer;b:string;
begin
i:=1;
b:='';
while i<=10 do
begin
b:=b+inttostr(i)+'';
i:=i+1;
end;
label3.Caption:=b;
end;
procedure TForm1.RepeatUntilClick(Sender: TObject);
var
i,j:integer;b:string;
begin
i:=1;
b:='';
repeat
b:=b+inttostr(i)+'';
i:=i+1;
until i>10;
label4.caption:=b;
end;
procedure TForm1.bt_pangkatClick(Sender: TObject);
var
bil,hasil,pangkat,a:integer;
begin
bil:=strtoint(edit1.Text);
hasil:=bil;
pangkat:=strtoint(edit2.Text);
if edit2.text='0'then edit3.Text:='1'else
if edit2.text='1'then edit3.Text:=edit1.text else
begin
for a:=2 to pangkat do
hasil:=hasil*bil;
edit3.Text:=inttostr(hasil);
end;
end;
procedure TForm1.BinputClick(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.clear;
label1.Caption:='';
label2.Caption:='';
label3.Caption:='';
label4.Caption:='';
end;
end.
2. Running Program
Sabtu, 05 Mei 2012
Sabtu, 24 Maret 2012
Program Menghitung Kombinasi
PERTEMUAN KE 5 TANGGAL 21 MARET 2012
SEMESTER 2D
TUGAS 3:
- Buat Program Untuk Menghitung Kombinasi.
- Program Untuk Menghitung Kombinasi
USES WINCRT;
VAR
N,R,NR,F1,F2,F3:REAL;
C:REAL;
PROCEDURE FAK(VAR F,HASIL:REAL);
VAR I:INTEGER;
BEGIN
HASIL:=1;
I:=1;
WHILE I<=F DO
BEGIN
HASIL:=HASIL*I;
I:=I+1;
END;
END;
BEGIN
WRITE('-----------PROGRAM MENGHITUNG KOMBINASI------------');
WRITELN;
WRITELN;
WRITELN('MASUKKAN DATA YANG AKAN DIKOMBINASIKAN!');
WRITELN;
WRITE('Banyaknya Data Yang dikombinasikan ='); READLN(N);
WRITE('Banyaknya Kombinasi ='); READLN(R);
NR:=N-R;
FAK(N,F1);
FAK(NR,F2);
FAK(R,F3);
C:=F1/(F2*F3);
WRITELN('Jumlah Kombinasi Yang Terjadi =',c:1:0);
END.
2. Layout Program
Jumat, 09 Maret 2012
Program CASHIER
PERTEMUAN KE 3 TANGGAL 7 MARET 2012
SEMESTER 2D
TUGAS 2:
- Buat Program Menampilkan Rincian Uang.
- Program Untuk Menampilkan Rincian Uang
PROGRAM DETAIL_MONEY;
USES WINCRT;
VAR
A,B,C,D,E,F,G,H,I,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z : longint;
BEGIN
WRITELN('HOW MUCH MONEY DO YOU GET BACK ??');
WRITELN;
WRITE('Total Payment = '); readln(A);
WRITE('Cash Payment = '); readln(B);
C:=B-A;
WRITELN('Cash Back = ',C);
WRITELN('With Detail Money As Below :');
D:=C MOD 100000;
P:=C DIV 100000;
E:=D MOD 50000;
Q:=D DIV 50000;
F:=E MOD 20000;
R:=E DIV 20000;
G:=F MOD 10000;
S:=F DIV 10000;
H:=G MOD 5000;
T:=g DIV 5000;
I:=H MOD 2000;
U:=H DIV 2000;
J:=I MOD 1000;
V:=I DIV 1000;
K:=J MOD 500;
W:=J DIV 500;
L:=K MOD 200;
X:=K DIV 200;
M:=L MOD 100;
Y:=L DIV 100;
N:=M MOD 50;
Z:=M DIV 50;
IF P>0 THEN WRITELN('100000 =',P);
IF Q>0 THEN WRITELN('50000 =',Q);
IF R>0 THEN WRITELN('20000 =',R);
IF S>0 THEN WRITELN('10000 =',S);
IF T>0 THEN WRITELN('5000 =',T);
IF U>0 THEN WRITELN('2000 =',U);
IF V>0 THEN WRITELN('1000 =',V);
IF W>0 THEN WRITELN('500 =',W);
IF X>0 THEN WRITELN('200 =',X);
IF Y>0 THEN WRITELN('100 =',Y);
IF Z>0 THEN WRITELN('50 =',Z);
WRITELN;
WRITELN('Thank You, :)');
END.
2. Layout Program
Sabtu, 03 Maret 2012
Program PERKALIAN MATRIX
PERTEMUAN KE 2 TANGGAL 29 FEBRUARI 2012
SEMESTER 2D
TUGAS 1 :
- Buat Program Untuk Perkalian Dua Matrix
- Buat Program Untuk Menampilkan Matrix Identitas Terbalik
- Program Pascal Untuk Menghitung Perkalian Dua Matrix
PROGRAM MULTIPLICATION_OF_TWO_MATRIX;
USES WINCRT;
VAR
A,B,C : ARRAY [1..10,1..10] OF INTEGER;
I,J,K,X,Y,Z : INTEGER;
BEGIN
WRITELN('MULTIPLICATION PROGRAM OF TWO MATRIX');
WRITELN;
WRITELN('Ordo Of Matrix A');
WRITE('Row : '); READLN(X);
WRITE('Column : '); READLN(Y);
CLRSCR;
WRITELN('Ordo Of Matrix B');
WRITELN('Row : ',Y);
WRITE('Collumn : '); READLN(Z);
CLRSCR;
WRITELN ('Input Elemens of Matrix A');
FOR I:=1 TO x DO
FOR j:=1 TO y DO
BEGIN
WRITE('A[',i,',',j,'] : ');READLN(A[I,J]);
END;
WRITELN;
WRITELN ('Input Elemens of Matrix B');
FOR I:=1 TO Y do
FOR J:=1 TO Z do
BEGIN
WRITE('B[',I,',',J,'] : '); READLN(B[I,J]);
END;
FOR I:=1 TO X DO
FOR J:=1 TO Z DO
FOR k:=1 TO Y DO
C[I,J] := C[I,J] + A[I,K]*B[K,J];
WRITELN;
WRITELN;
WRITELN('Result Of Multiplication Matrix A and Matrix B : ');
WRITELN;
FOR I:=1 TO X DO
BEGIN
FOR J:=1 TO Z DO
WRITE(C[I,J],' ');
WRITELN;
END;
END.
1.2 Layout Program
PROGRAM MATRIX;
USES WINCRT;
VAR
A,B,C :ARRAY[1..10,1..10] OF INTEGER;
X,Y,KOL,BAR:INTEGER;
BEGIN
FOR X:=1 to 5 DO
BEGIN
FOR Y:=1 to 5 DO
BEGIN
C[X,Y] := 0;
IF X+Y=6 THEN C[X,Y]:=1;
WRITE(C[X,Y]:4);
END;
WRITELN;
END;
END.
2.2 Layout Program
Langganan:
Postingan (Atom)