Tuesday, June 12, 2012

Pascal Program Menu Deret Bilangan

,





uses crt;
var
a,i,j,z,k,c : integer;
pil:integer;
simpan : array[0..100] of integer;
jwb : string;
label
P,Q,R,S,T,U,W,X;
Begin
clrscr;

W:clrscr;
  Writeln('                            Program Menu Deret Bilangan ');
  writeln('                            -------RIZKA FAJRIAH-------');writeln;
  writeln('Silahkan Pilih Menu Deret');
  writeln;
  writeln('_______________MENU DERET_______________');
  writeln('    ','1.  Deret Bil. Genap & Ganjil');
  writeln('    ','2.  Deret Bil. Kuadrat & Kubik');
  writeln('    ','3.  Deret Bil. Fibonacci');
  writeln('    ','4.  Deret Bil. Persegi Panjang');
  writeln('    ','5.  Deret Bil. Balok');
  writeln('    ','6.  Deret Bil. Prima');
  writeln('    ','7.  Exit');
  writeln('________________________________________');
  writeln;
  writeln;

  write('     ','Menu Deret Pilihan Anda adalah',' ');
  readln(pil);
  case pil of
  1:Goto P;
  2:Goto Q;
  3:Goto R;
  4:Goto S;
  5:Goto T;
  6:Goto U;
  7:Goto X;
  8:Goto W;
  End;

P :  begin
     clrscr;
     writeln('Deret Bilangan Ganjil & Genap');
     writeln;
     write ('Masukkan Angka : ');readln(a);
     writeln;

     writeln('Bilangan Ganjil sampai dengan','  ' ,a, ' adalah');

           for i := 1 to a do
           begin
           j := ( 2 * i ) - 1 ;
           write(j,' ');
           end;
           writeln;
           writeln;

     writeln('Bilangan Genap sampai dengan','  ' ,a, ' adalah');

           for z:= 1 to a do
                begin
                k := (2 * z);
                read;
                write(k,' ');
                end;
  readkey;
  end;
  writeln;
  writeln;
  writeln('    ','Kembali (Ya / Tdk) ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto W
  else
  Goto X;

Q: begin
     clrscr;
     writeln('Deret Bilangan Kuadrat & Kubik');
     writeln;
     write ('Masukkan angka : ');readln(a);writeln;

           Writeln('Hasil Kuadrat sampai dengan','  ',a,'  ','adalah');
           writeln;
           for i := 1 to a do
           begin
           j := i * i ;
           write(j,' ');
           end;
           writeln;
           writeln;
           writeln;
           Writeln('Hasil Kubik sampai dengan','  ',a,'  ','adalah');
           writeln;
           for z:= 1 to a do
                begin
                k := z*z*z;
                write(k,' ');
                read;
                end;
  readkey;
  end;
  writeln;
  writeln;
  writeln('    ','Kembali (Ya / Tdk) ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto W
  else
  Goto X;

R:begin
      clrscr;
      writeln('Deret Bilangan Fibonacci');
      writeln;
      write('Masukkan Jumlah Looping : ');readln(a);
      writeln;
      Writeln('Hasil Bilangan Fibonacci sampai dengan','  ',a,'  ','adalah');
      writeln;
      for i:= 0 to a do
      begin
       if (i=0) or (i=1) then
       begin
       simpan[i]:=1;
       write(simpan[i],' ');
       end
       else
       begin
       simpan[i] := simpan[i-1]+simpan[i-2];
       write(simpan[i],' ');
       end;
      end;
      readln;
  end;
  writeln;
  writeln;
  writeln('    ','Kembali (Ya / Tdk) ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto W
  else
  Goto X;

S:begin
     clrscr;
     writeln('Deret Bilangan Persegi Panjang');
     writeln;
     write ('Masukkan angka : ');readln(a);
     writeln;
     Writeln('Hasil Bilangan Persegi Panjang sampai dengan','  ',a,'  ','adalah');
     writeln;
           for i := 1 to a do
           begin
           j := i * (i + 1);
           write(j,' ');
           read;
           end;
  readkey;
  end;
  writeln;
  writeln;
  writeln('    ','Kembali (Ya / Tdk) ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto W
  else
  Goto X;

T:begin
     clrscr;
     writeln('Deret Bilangan Balok');
     writeln;
     write ('Masukkan angka : ');readln(a);
     writeln;
     Writeln('Hasil Bilangan Balok sampai dengan','  ',a,'  ','adalah');
     writeln;

           for i := 1 to a do
           begin
           j := i * ( i + 1 ) * ( i +  2) ;
           write (j,' ');
           read;
           end;
  readkey;
  end;
  writeln;
  writeln;
  writeln('    ','Kembali (Ya / Tdk) ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto W
  else
  Goto X;

U:begin
     clrscr;
     writeln('Deret Bilangan Prima');
     writeln;
     write('Masukkan batas deret :',' ');readln(a);writeln('');
     writeln;
     writeln('Bilangan Prima dari',' ',a,' adalah');
     writeln;
     for j:=1 to a do
      begin
       c:=0;
        for i := 1 to j do
            begin
            if j mod i=0 then
            c:=c+1;
            end;
        if c=2 then
        write(j:3);
        end;
        readln;
  end;
  writeln;
  writeln;
  writeln('    ','Kembali (Ya / Tdk) ?');
  writeln;
  write('       Jawab :   ');readln(jwb);
  if jwb = 'Ya' then
  Goto W
  else
  Goto X;

X : writeln;
    Writeln;
    Writeln;
    Writeln('                 ','__SAMPAI JUMPA LAGI__ ');
    Writeln;
    Writeln('                 ','SEMOGA BERMANFAAT  :-)');
    readln;
    end.



2 comments :