Menu

15 03 2010

Program 1 :

uses crt;
var
pil, n, i, j : integer;
nama, kelas, npm : string;
c,f,r,k : real;
jwb : char;
label
selesai, menu;

begin
menu:
clrscr;
writeln(‘=============’);
writeln(‘ Menu ‘);
writeln(‘=============’);
writeln(‘1.Biodata’);
writeln(‘2.Suhu’);
writeln(‘3.Deret’);
writeln(‘4.Keluar’);
write(‘Masukkan Pilhan Anda: ‘);
readln(pil);
case pil of
1 : begin
clrscr;
write(‘Masukkan Nama : ‘);
readln(nama);
write(‘Masukkan Kelas : ‘);
readln(kelas);
write(‘Masukkan NPM : ‘);
readln(npm); writeln;
writeln(‘Nama Anda Adalah :’, nama);
writeln(‘Kelas Anda :’, kelas);
writeln;
write(‘Kembali Ke Menu [Y/T] : ‘);
readln(jwb);
if (jwb = ‘Y’) or (jwb = ‘y’) then
goto menu
else
goto selesai;
end;
2 : begin
clrscr;
write(‘Masukkan derajat celcius : ‘);
readln(c);
r:=4/5*c;
writeln(‘Derajat Reamurnya : ‘,r:3:1);
f:=(9/5)*c+32;
writeln(‘Derajat Fahrenheit : ‘,f:3:1);
k:=c+100;
writeln(‘Derajat Kelvin : ‘,k:3:1);
readln;
write(‘Kembali Ke Menu [Y/T] : ‘);
readln(jwb);
if (jwb = ‘Y’) or (jwb = ‘y’) then
goto menu
else
goto selesai;
end;
3 : begin
clrscr;
write(‘Masukkan Banyaknya Deret :’);
readln(n);
for i := 1 to n do
begin
for j := 1 to i do
begin
write(j);
end;
writeln;
end;
readln;
end;
4 : goto selesai;
end;

selesai:
clrscr;
writeln(‘Terima Kasih’);
readln;
end.

Program 2 :

uses crt;
type
matrix= array[1..25,1..25] of integer;
var
pil : char;
i,j,k,pjg,lbr,ls,deret,y,z,a,b, n,bts : integer;
x : array [1..100] of longint;
nama: string;
matA, matB: matrix;

procedure InputMat(var x:matrix);
begin
for i := 1 to a do
begin
for j := 1 to b do
begin
write(‘Masukan elemen[‘,i,’][‘,j,’: ‘); readln(x[i,j]);
end;
end;
end;

procedure CetakMat(var x:matrix);
begin
for i:= 1 to a do
begin
for j:=1 to b do
begin
write(x[i,j], ‘ ‘);
end;
writeln;
end;
end;

procedure JumMat(var x, y:matrix);
var z:matrix;
begin
for i:=1 to a do
begin
for j:=1 to b do
begin
z[i,j]:=x[i,j]+y[i,j];
write(z[i,j]:4);
end;
writeln;
end;
end;

begin
clrscr;
writeln(‘<<MENU UTAMA>>’);
write(‘Pilihan Anda : ‘); readln(pil);
case pil of
‘1’: begin
clrscr;
write(‘Nama Anda : ‘); readln(nama);
writeln;
writeln(‘Nama Anda adalah ‘, nama);
end;
‘2’: begin
clrscr;
write(‘Input jumlah deret : ‘); readln(deret);
for i := 1 to deret do
begin
for j := 1 to i do
begin
write(j);
end;
writeln;
end;
end;
‘3’: begin
clrscr;
write(‘Input jml deret: ‘); readln(deret);
for i := 1 to deret do
begin
for j := 1 to i do
begin
write(j*i, ‘ ‘);
end;
writeln;
end;
end;
‘4’: begin
clrscr;
write(‘jml deret: ‘); readln(n);
writeln;
for i := 0 to n-1 do
begin
if (i = 0) or (i=1) then
begin
x[i]:=1;
write(x[i], ‘ ‘);
end
else
begin
x[i]:=x[i-1]+x[i-2];
write(x[i], ‘ ‘);
end;
end;
end;
‘5’: begin
clrscr;
write(‘Jumlah Deret : ‘); readln(n);
x[1]:=1;
writeln(1);
for i:=1 to n do
begin
bts:=(i+1) div 2;
if not odd(i) then
x[bts+1]:=x[bts]*2;
for j:= bts downto 2 do
x[j]:=x[j]+x[j-1];
for j:= 1 to bts do
write(x[j], ‘ ‘);
if not odd(i) then write(x[i+1], ‘ ‘);
for j:= bts downto 1 do
write(x[j], ‘ ‘);
writeln;
end;
end;
‘6’: begin
clrscr;
write(‘Masukan jml baris: ‘); readln(a);
write(‘Masukan jml kolom: ‘); readln(b);
writeln(‘Input Matrix A’);
InputMat(matA);
writeln(‘Input Matrix B’);
InputMat(matB);
writeln;
CetakMat(matA);
writeln;
CetakMat(matB);
writeln;
writeln(‘Jumlahnya’);
JumMat(matA,matB);
end;
end;
readln;
end.


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: