Senin, 23 Maret 2015

REKURSIF

 Contoh program Bangun Ruang
Source Code:
uses crt;
label
     lagi;
var Bangun,S,P,L,T,LA,R,n : integer;
    tanya: char;
    V1,V2,V3,V4,V5   : real;
begin
clrscr;
lagi:
 writeln ('Nama : CAHYA KARIMA  ');
 writeln ('NIM  : J1F114014          ');

GotoXY(16,3); writeln ('       Perhitungan Bangun Ruang  ');
GotoXY(15,4); writeln ('*========================================*');
GotoXY(20,5); writeln ('1.Hitung Volume Kubus                ');
GotoXY(20,6); writeln ('2.Hitung Volume Balok                ');
GotoXY(20,7); writeln ('3.Hitung Volume Prisma               ');
GotoXY(20,8); writeln ('4.Hitung Volume Kerucut              ');
GotoXY(20,9); writeln ('5.Hitung Volume Limas                ');
GotoXY(15,10); writeln ('==========================================');

GotoXY(15,11); write ('Masukkan pilihan Anda: '); readln (n);
writeln;

         if n=1 then
         begin
           writeln ('Menghitung Luas Volume Kubus');
           writeln ('============================================');
           write ('Sisi:  '); readln(S);
             V1:=S*S*S;
           writeln ('Volume Kubus= ',V1:2:2);
             readln;
        end
      else
      if n=2 then
      begin
       writeln ('Mengitung Luas Volume Balok');
       writeln ('=================================');
       write('Panjang     : '); readln(P);
       write('Lebar       : '); readln(L);
       write('Tinggi      : '); readln(T);
         V2:=P*L*T;
       writeln ('Volume Balok = ',V2:2:2);
readln;
end
else

    if n=3 then
    begin
       writeln('Menghitung Luas Volume Prisma');
       writeln('==================================');
       write('Luas ALas : '); readln(LA);
       write('Tinggi    : '); readln(T);
       V3:=LA*T;
       writeln('Volume Prisma = ',V3:2:2);
  readln;
end
else
   if n=4 then
      begin
       writeln ('Mengitung Luas Volume Kerucut');
       writeln ('=================================');
       write('Jari-jari : '); readln(R);
       write('Tinggi    : '); readln(T);
         V4:=pi*R*R*T*(1/3);
       writeln ('Volume Kerucut= ',V4:2:2);
   readln;
end
else
 if n=5 then
      begin
       writeln ('Mengitung Luas Volume Limas');
       writeln ('=================================');
       write('Luas Alas     : '); readln(LA);
       write('Tinggi      : '); readln(T);
         V5:=(1/3)*LA*T;
       writeln ('Volume Limas= ',V5:2:2);
readln;
end
  else
  begin
       Gotoxy(20,16); writeln('Pilihan Anda Tidak ada di Menu...');
  end;

       writeln;
       write ('Ingin menghitung lagi [Y/T] ? '); readln(tanya);
  if tanya=upcase('y') then
  begin
       clrscr;
       goto lagi;
  end
  else
       clrscr;
       gotoxy(30,30); writeln ('TERIMAKASIH');
  readln;
end.

 Output:









Tidak ada komentar:

Posting Komentar