TUGAS 5
YENI HIDAYANA
111221141
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Fortodo: TButton;
Fordowntodo: TButton;
Whiledo: TButton;
Repeatuntil: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
btkeluar: TButton;
Label5: TLabel;
Edit1: TEdit;
Label6: TLabel;
Edit2: TEdit;
Label7: TLabel;
Edit3: TEdit;
btpangkat: TButton;
procedure FortodoClick(Sender: TObject);
procedure FordowntodoClick(Sender: TObject);
procedure WhiledoClick(Sender: TObject);
procedure RepeatuntilClick(Sender: TObject);
procedure btkeluarClick(Sender: TObject);
procedure btpangkatClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
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 (j)+' ';
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.btkeluarClick(Sender: TObject);
begin
close;
end;
procedure TForm1.btpangkatClick(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;
end.
HASIL RUNNING :
YeniHidayana
Minggu, 06 Mei 2012
Sabtu, 24 Maret 2012
TUGAS 4
Program Kombinasi_Faktorial;
uses wincrt;
var f1,f2,f3:longint;
n,r,nr:integer;
c: real;
Procedure fact( n:integer; var f:longint);
var i:integer;
begin
f:=1;
for i:=1 to n do
f:= f * i;
end;
Begin
writeln('Yeni Hidayana');
writeln('Program Kombinasi Faktorial');
writeln(' ');
write('Masukkan data yang akan di kombinasikan :',' ');readln(n);
write('Masukkan jumlah kombinasi :',' ');readln(r);
fact(n,f1);
fact(r,f2);
nr:=(n-r);
fact(nr,f3);
c:= f1/(f2*f3);
writeln(' ');
write('hasilnya adalah :',' ',c:2:0);
readln;
end.
Hasil tampilannya
Program Kombinasi_Faktorial;
uses wincrt;
var f1,f2,f3:longint;
n,r,nr:integer;
c: real;
Procedure fact( n:integer; var f:longint);
var i:integer;
begin
f:=1;
for i:=1 to n do
f:= f * i;
end;
Begin
writeln('Yeni Hidayana');
writeln('Program Kombinasi Faktorial');
writeln(' ');
write('Masukkan data yang akan di kombinasikan :',' ');readln(n);
write('Masukkan jumlah kombinasi :',' ');readln(r);
fact(n,f1);
fact(r,f2);
nr:=(n-r);
fact(nr,f3);
c:= f1/(f2*f3);
writeln(' ');
write('hasilnya adalah :',' ',c:2:0);
readln;
end.
Hasil tampilannya
Sabtu, 10 Maret 2012
TUGAS 3 :
Program kembalian_uang_belanja;
uses wincrt;
var
uang,bayar,kembali : longint;
begin
writeln('****Yeni Hidayana****');
write('Jumlah Bayar : ');readln(bayar);
writeln('----------------------------');
write('Jumlah Uang : ');readln(uang);
writeln('----------------------------');
kembali:=uang-bayar;
writeln('Total Kembali : ',kembali);
writeln('----------------------------');
if kembali div 100000 > 0 then begin
writeln(kembali div 100000, ' lembar seratus ribuan ');
kembali := kembali mod 100000;
end;
if kembali div 50000 > 0 then begin
writeln(kembali div 50000, ' lembar lima puluh ribuan ');
kembali := kembali mod 50000;
end;
if kembali div 20000 > 0 then begin
writeln(kembali div 20000, ' lembar dua puluh ribuan');
kembali := kembali mod 20000;
end;
if kembali div 10000 > 0 then begin
writeln(kembali div 10000, ' lembar sepuluh ribuan');
kembali := kembali mod 10000;
end;
if kembali div 5000 > 0 then begin
writeln(kembali div 5000, ' lembar lima ribuan');
kembali := kembali mod 5000;
end;
if kembali div 1000 > 0 then begin
writeln(kembali div 1000, ' lembar seribuan');
kembali := kembali mod 1000;
end;
if kembali div 500 > 0 then begin
writeln(kembali div 500, ' keping lima ratusan');
kembali := kembali mod 500;
end;
if kembali div 200 > 0 then begin
writeln(kembali div 200, ' keping dua ratusan');
kembali := kembali mod 200;
end;
if kembali div 100 > 0 then begin
writeln(kembali div 100, ' keping seratusan');
kembali := kembali mod 100;
end;
if kembali div 50 > 0 then begin
writeln(kembali div 50, ' keping lima puluhan');
kembali := kembali mod 50;
end;
writeln('**** THANKS 4 COMING ****');
end.
Program kembalian_uang_belanja;
uses wincrt;
var
uang,bayar,kembali : longint;
begin
writeln('****Yeni Hidayana****');
write('Jumlah Bayar : ');readln(bayar);
writeln('----------------------------');
write('Jumlah Uang : ');readln(uang);
writeln('----------------------------');
kembali:=uang-bayar;
writeln('Total Kembali : ',kembali);
writeln('----------------------------');
if kembali div 100000 > 0 then begin
writeln(kembali div 100000, ' lembar seratus ribuan ');
kembali := kembali mod 100000;
end;
if kembali div 50000 > 0 then begin
writeln(kembali div 50000, ' lembar lima puluh ribuan ');
kembali := kembali mod 50000;
end;
if kembali div 20000 > 0 then begin
writeln(kembali div 20000, ' lembar dua puluh ribuan');
kembali := kembali mod 20000;
end;
if kembali div 10000 > 0 then begin
writeln(kembali div 10000, ' lembar sepuluh ribuan');
kembali := kembali mod 10000;
end;
if kembali div 5000 > 0 then begin
writeln(kembali div 5000, ' lembar lima ribuan');
kembali := kembali mod 5000;
end;
if kembali div 1000 > 0 then begin
writeln(kembali div 1000, ' lembar seribuan');
kembali := kembali mod 1000;
end;
if kembali div 500 > 0 then begin
writeln(kembali div 500, ' keping lima ratusan');
kembali := kembali mod 500;
end;
if kembali div 200 > 0 then begin
writeln(kembali div 200, ' keping dua ratusan');
kembali := kembali mod 200;
end;
if kembali div 100 > 0 then begin
writeln(kembali div 100, ' keping seratusan');
kembali := kembali mod 100;
end;
if kembali div 50 > 0 then begin
writeln(kembali div 50, ' keping lima puluhan');
kembali := kembali mod 50;
end;
writeln('**** THANKS 4 COMING ****');
end.
Minggu, 04 Maret 2012
TUGAS
1. Buat program untuk perkalian 2 matrik!
uses wincrt;
var
a,b,c : array [1..5,1..5] of integer;
i,j,k,x,y,z : integer;
begin
clrscr;
writeln('Selamat datang di program perkalian 2 matriks');
writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
writeln('----------------------------------------');
writeln ('nama :yeni hidayana');
writeln('Ukuran matrix A');
write('Baris : '); readln(x);
write('Kolom : '); readln(y);
writeln;
writeln('Ukuran matrix B');
writeln('Baris : ',y);
write('Kolom : '); readln(z);
writeln('----------------------------------------');
for i:=1 to x do
for j:=1 to y do
begin
write('Elemen A[',i,',',j,'] : ');
readln(a[i,j]);
end;
writeln;
for i:=1 to y do
for j:=1 to z do
begin
write('Elemen 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('Hasil dari perkalian Matrix A dengan Matrix B adalah : ');
Writeln;
for i:=1 to x do
begin
for j:=1 to z do
write(c[i,j]:4);
writeln;
end;
writeln;
readln;
end.
var
a,b,c : array [1..5,1..5] of integer;
i,j,k,x,y,z : integer;
begin
clrscr;
writeln('Selamat datang di program perkalian 2 matriks');
writeln('Masukkan ukuran matrik Minim ordo 5 x 5 ');
writeln('----------------------------------------');
writeln ('nama :yeni hidayana');
writeln('Ukuran matrix A');
write('Baris : '); readln(x);
write('Kolom : '); readln(y);
writeln;
writeln('Ukuran matrix B');
writeln('Baris : ',y);
write('Kolom : '); readln(z);
writeln('----------------------------------------');
for i:=1 to x do
for j:=1 to y do
begin
write('Elemen A[',i,',',j,'] : ');
readln(a[i,j]);
end;
writeln;
for i:=1 to y do
for j:=1 to z do
begin
write('Elemen 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('Hasil dari perkalian Matrix A dengan Matrix B adalah : ');
Writeln;
for i:=1 to x do
begin
for j:=1 to z do
write(c[i,j]:4);
writeln;
end;
writeln;
readln;
end.
Hasil :
2. buat program untuk menampilkan matrik
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 1 0 0 0
1 0 0 0 0
program matrik_identitas_yenihidayana;
uses WinCrt;
var
mat:array[1..5,1..5]of integer;
x,y:integer;
begin
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
mat[x,y]:=0;
if x+y=6 then mat[x,y]:=1;
write (mat[x,y]:3);
end;
writeln;
end;
end.
uses WinCrt;
var
mat:array[1..5,1..5]of integer;
x,y:integer;
begin
for x:=1 to 5 do
begin
for y:=1 to 5 do
begin
mat[x,y]:=0;
if x+y=6 then mat[x,y]:=1;
write (mat[x,y]:3);
end;
writeln;
end;
end.
Hasil :
Rabu, 29 Februari 2012
Langganan:
Postingan (Atom)