Senin, 30 Maret 2015

Pascal > Program Menu

Program Menghitung_Luas_Bangun_Datar;              
Uses wincrt;
label akhir,awal;
Var menu:integer;
p,l,t,r,s,a,d1,d2,L1,L2,L3,L4,L5,L6:real;
YN: char;
begin
     begin
     awal:
     gotoxy(15,2); writeln(' == Program Menghitung Luas Bangun Datar ==');
     writeln;
     writeln (' Menu-Menu ');
     writeln;
     writeln('1. Persegi');
     writeln('2. Persegi Panjang');
     writeln('3. Layang-layang');
     writeln('4. Jajar Genjang');
     writeln('5. Segitiga');
     writeln('6. Lingkran');
     writeln('0. Selesai');
     writeln;
     write('Pilih Menu No: '); read(menu);
     end;
         case menu of
         1:begin
         repeat
         clrscr;
         gotoxy(32,2); writeln('== Persegi ==');
         writeln;
         write('Masukkan Nilai Sisi Persegi= '); readln(s);
         L1:=s*s;
         writeln('..............................');
         writeln('Jadi Luas Persegi = ',L1:0:0,'cm2');
         write('Coba lagi? (Y or N):'); readln (YN);
         until (YN='N') or (YN= 'n');
         clrscr;
         goto awal                              
         end;
         2:begin
         repeat
         clrscr;
         gotoxy(28,2); writeln('== Persegi Panjang ==');
         writeln;
         write('-Masukkan Nilai p (panjang) = ');readln(p);
         write('-Masukkan Nilai l (lebar) = ');readln(l);
         L2:=p*l;
         writeln('..............................');
         writeln('Jadi Luas Persegi Panjang = ',L2:0:0,' cm2 ');
         write('Coba lagi? (Y or N):'); readln (YN);
         until (YN='N') or (YN='n');             
         clrscr;
         goto awal
         end;
         3:begin
         clrscr;
         gotoxy(29,2); writeln('== Layang-layang ==');
         writeln;
         write('-Masukkan Nilai d1 (diagonal satu)= '); readln(d1);
         write('-Masukkan Nilai d2 (diagonal dua)= '); readln(d2);
         L3:=1/2*d1*d2;
         writeln('..............................');
         writeln('Jadi Luas Layang-layang = ',L3:10:2,' cm2 ');
         write('Coba lagi? (Y or N):');  readln(YN);
         readln;
         clrscr;
         goto awal
         end;
         4:begin
         repeat
         clrscr;
         gotoxy(29,2); writeln('== Jajar Genjang ==');

         writeln;
         write('-Masukkan Nilai a (alas) = '); readln(a);
         write('-Masukkan Nilai t (tinggi) = '); readln(t);
         L4:=a*t;
         writeln('..............................');
         writeln('Jadi Luas Jajar Genjang = ',L4:10:2,' cm2 ');
         write('Coba lagi? (Y or N):'); readln (YN);
         until (YN='N') or (YN='n');             
         clrscr;
         goto awal
         end;
         5:begin
         repeat
         clrscr;
         gotoxy(31,2); writeln('== Segitiga ==');
         writeln;
         write('-Masukkan Nilai a (alas) = '); readln(a);
         write('-Masukkan Nilai t (tinggi) = '); readln(t);
         L5:=1/2*a*t;
         writeln('..............................');
         writeln('Jadi Luas Segitiga = ',L5:10:2,' cm2 ');
         write('Coba lagi? (Y or N):'); readln (YN);
         until (YN='N') or (YN='n');             
         clrscr;
         goto awal
         end;
         6:begin
         repeat
         clrscr;
         gotoxy(31,2); writeln('== Lingkaran ==');
         writeln;
         write('-Masukkan Nilai r (jari-jari) = '); readln(r);
         L6:=pi*r*r;
         writeln('..............................');
         writeln('Jadi Luas Lingkaran = ',L6:10:2,' cm2 ');
         write('Coba lagi? (Y or N):'); readln (YN);
         until (YN='N') or (YN='n');             
         clrscr;
         goto awal
         end;
         0:begin
         clrscr;
         goto akhir
         end;
     end;
     akhir:
     end.























































































































coding diatas adalah contoh bagaimana cara untuk membuat program menu menggunakan pascal dengan materi ''menghitung luas bangun datar''.

Semoga Bermanfaat ^-^





0 komentar:

Posting Komentar