Monday, April 8, 2013
Tugas Struktur Data Pascal || Volume Tabung Array Prosedur Record | Program Sederhana |
Sekedar sharing, kalo yang ini tugas 2 untuk NIM genap nyari volume tabung, mudah-mudahan bisa sedikit membantu.
program tugastabung;
uses crt;
type tabung = record
r : integer;
t : integer;
La : real;
Ls : real;
Ltt : real;
Ltot: real;
v : real;
end;
var tbg : tabung;
i,pilihan : integer;
lagi : char;
label lagii;
//ini cuma buat judul atau headernya doank gak terlalu penting
procedure spasi(x:integer);
begin
for i:=1 to x do
begin
write(' ');
end;
end;
procedure garis(x:integer);
begin
for i:=1 to x do
begin
write ('-');
end;
end;
procedure batas;
begin
write('|');
end;
procedure judul;
begin
gotoxy(17,2); batas; garis(45); batas;
gotoxy(17,3); write('|Program Sederhana Penghitungan Volume Tabung|');
gotoxy(17,4); write('|Procedure With "With" & Without "With" LOL!! |');
gotoxy(17,5); batas; garis(45); batas;
gotoxy(17,6); batas; spasi(10);write('Dicky Prastianto Pramudya'); spasi(10); batas;
gotoxy(17,7); batas; spasi(16);write('5520 111 097'); spasi(17); batas;
gotoxy(17,8); batas; spasi(19);Write('TI.IV-4'); spasi(19); batas;
gotoxy(17,9); batas; garis(45);batas;
gotoxy(1,25); spasi(32); write('*Program Konyol*'); spasi(32);
end;
//yang ini prosedur yang pake with
procedure usewith;
begin
clrscr;
judul;
gotoxy(1,12);
with tbg do
begin
writeln('Ini Menggunakan "With" Lho! ');
writeln;
write('Jari-jari Kerucut : '); readln(r);
write('Tinggi Kerucut : '); readln(t);
writeln;
La := pi * sqr(r);
Ls := 2 * pi * r * t;
Ltt := La + Ls;
Ltot := Ltt + La;
v := La * t;
writeln('Luas Alas :', La:8:2);
writeln('Luas Selimut Tabung :', Ls:8:2);
writeln('Luas Permukaan Tabung Tanpa Tutup :', Ltt:8:2);
writeln('Luas Seluruh Permukaan Tabung :', Ltot:8:2);
writeln('Volume Tabung :', v:8:2);
writeln;
garis(30);
writeln;
end;
end;
//kalo yang ini prosedur gak pake with lebih ribet
procedure withoutwith;
begin
clrscr;
judul;
gotoxy(1,12);
writeln('Ini Gak Pake "With" Lho! ');
writeln;
write('Jari-jari Kerucut : '); readln(tbg.r);
write('Tinggi Kerucut : '); readln(tbg.t);
tbg.La := pi * sqr(tbg.r);
tbg.Ls := 2 * pi * tbg.r * tbg.t;
tbg.Ltt := tbg.La + tbg.Ls;
tbg.Ltot := tbg.Ltt + tbg.La;
tbg.v := tbg.La * tbg.t;
writeln;
writeln('Luas Alas :', tbg.La:8:2);
writeln('Luas Selimut Tabung :', tbg.Ls:8:2);
writeln('Luas Permukaan Tabung Tanpa Tutup : ',tbg.Ltt:8:2);
writeln('Luas Seluruh Permukaan Tabung :', tbg.Ltot:8:2);
writeln('Volume Tabung :', tbg.v:8:2);
writeln;
garis(30);
writeln;
end;
//ini baru program utama
Begin
lagii:
clrscr;
judul; //manggil prosedur judul
gotoxy(1,12);
writeln('1. Penghitungan Luas & Volume Tabung dengan "With" ');
writeln('2. Penghitungan Luas & Volume Tabung Tanpa "With" ');
garis(50);writeln;
spasi(3);
write('Mau yang mana ? 1 atau 2? : '); readln(pilihan);
if (pilihan = 1) then usewith
else if (pilihan = 2) then withoutwith
else
begin
writeln;
writeln;
write('Pilihannya Cuma 1 & 2 Lho!');
end;
write('Mau Menghitung Lagi [Y or N]?'); readln(lagi);
if (lagi ='y') or (lagi ='Y') then goto lagii
else if (lagi='N') or (lagi='n') then end.
readln;
End.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment