Sunday, November 29, 2015

Program Menu Pilihan


--------------------------------------------------------------------------------------------------------------------------
program Menu_pilihan;
uses crt;
var
i,j,n,x,y,jml,hasil : integer;
pil                 :integer;
rata                : real;
nilai               : array[1..100] of integer;
jwb                 : string;

label
D,E,F,G,Menu,H,Keluar;

Begin
clrscr;
Menu :clrscr;
  Writeln('                               PROGRAM MENU PILIHAN ');
  writeln('                                   YUDI RAMDANI     ');writeln;
  writeln('     ','Silahkan Pilih Menu Di Bawah ini');
  writeln;
  writeln('-------------------------------------------------');
  writeln('| NO    |          MENU PILIH                   |');
  writeln('-------------------------------------------------');
  writeln('| ','1  | MENGHITUNG M x N DENGAN OPERATOR PLUS    |');
  writeln('| ','2  | MEMBUAT BARISAN FIBONACCI                |');
  writeln('| ','3  | MENCARI SUKU KE-N                        |');
  writeln('| ','4  | MENGHITUNG RATA - RATA                   |');
  writeln('| ','5  | Exit                                     |');
  writeln('-------------------------------------------------');
  writeln;
  writeln('-------------------------------------------------');
  write('  Menu Pilihan Anda adalah NO  = ');readln(pil);
  case pil of
  1:Goto D;
  2:Goto E;
  3:Goto F;
  4:Goto G;
  5:Goto Keluar;
  7:Goto H;
  8:Goto Menu;
  End;

  //Menghitung M x N menggunakan operator Plus
D:begin
     clrscr;
writeln('----------------------------------------');
writeln('|         MENGHITUNG M x N             |');
writeln('----------------------------------------');
write('masukkan bilangan ke-1: ');readln(x);
write('masukkan bilangan ke-2: ');readln(y);
if (x<0) and (y<0) then begin
 x:=-x;
 y:=-y;
 i:=1;
 while i<=x do
begin
 hasil:=hasil+y;
 inc(i);
end;
end else
 if (x<0) then
begin
 x:=-x;
 if (y<0) then
  y:=-y;
  i:=1 ;
 while (i<=x) do
begin
  hasil :=hasil+y;
  inc(i);
end;
 if y>0 then
  hasil:=-hasil;
end else begin
 i:=1;
 while (i<=x)do
begin
  hasil:= hasil+y;
  inc(i);
end;
end;
writeln('hasil perkaliannya: ',hasil);
readln;
end;
  writeln;
  writeln;
  writeln('    ','Kembali [Y/T] ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto Menu
  else
  if jwb = 'tidak' then
  Goto H;

  //Membuat barisan fibonacci : 1,1,2,3,5,8,13,...
E:begin
      clrscr;
writeln('----------------------------------------');
writeln('- MEMBUAT BARISAN FIBONACCI -');
writeln('----------------------------------------');
      write('Masukkan Jumlah Looping : ');readln(x);
      writeln;
      Writeln('Hasil Bilangan Fibonacci sampai dengan','  ',x,'  ','adalah');
      writeln;
      for i:= 1 to x do
      begin
       if (i=0) or (i=1) then
       begin
       nilai[i]:=1;
       write(nilai[i],' ');
       end
       else
       begin
       nilai[i] := nilai[i-1]+nilai[i-2];
       write(nilai[i],' ');
    end;
   end;
readln;
end;
  writeln;
  writeln;
  writeln('    ','Kembali [Y/T] ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto Menu
  else
  if jwb = 'tidak' then
  Goto H;

  //Menentukan Suku Ke-N dari barisan 1,1,2,3,5,8,13,...
F :  begin
nilai[1]:=1; nilai[2]:=1;
ClrScr;
writeln('----------------------------------------');
writeln('- MENCARI SUKU KE-N -');
writeln('----------------------------------------');
writeln('Anda mencari suku ke : '); readln(n);
writeln;
write(nilai[1],' ');
write(nilai[2],' ');
for i:=3 to n do
begin
nilai[i]:=nilai[i-1]+nilai[i-2];
write(nilai[i],' ');
end;
writeln;
writeln('----------------------------------------');
writeln('Suku ke ',i,' = ',nilai[i]);
readln;
end;
  writeln;
  writeln;
  writeln('    ','Kembali [Y/T] ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto Menu
  else
  if jwb = 'tidak' then
  Goto H;

  //Menghitung rata - rata bilangan genap dari 1-100
G: begin
     clrscr;
writeln('----------------------------------------');
writeln('- MENGHITUNG RATA - RATA -');
writeln('----------------------------------------');
write('Input nilai akhir (+) : ');readln(x);
   for i := 1 to x do
   begin
    if i mod 2 = 0
     then
      jml := i div j;
   j := 2;
   end;
   writeln('Rata-rata Bilangan Genap dari 1 - 100 adalah ',jml);
   readln;
end;
  writeln;
  writeln;
  writeln('    ','Kembali [Y/T] ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto Menu
  else
  if jwb = 'tidak' then
  Goto H;

H : writeln;
    Writeln;
    Writeln;
    Writeln('                 ','~~~~~~~~~~~Terima Kasih~~~~~~~~~~~~');
    Writeln;
    Writeln('                 ','  Telah Menggunakan Program Saya   ');
    Writeln;
    Writeln('                 ','        SEMOGA BERMANFAAT          ');
    readln;

Keluar : writeln;

end.
--------------------------------------------------------------------------------------------------------------------------
Download Scriptnya :

catatan :
hargailah tulisan orang lain, jika anda mengcopy-paste harap cantumkan link sumber.
Load disqus comments

0 komentar