program Menu_Pilihan;
uses crt;
var
pilihan : byte;
n,i,suku,m,o : integer;
faktorial: real;
a,b,c: integer;
kali,x,y: integer;
begin
repeat
clrscr;textcolor(0);
textbackground(BLUE);clrscr;
window(12,7,68,19);textbackground(CYAN);clrscr;
gotoxy(23,2);write('MENU PILIHAN');
gotoxy(23,3);write('============');
gotoxy(3,4);
write('1. Menghitung Faktorial');
gotoxy(3,5);
write('2. Menentukan Suku ke-N dari Barisan : 3,6,9,36..');
gotoxy(3,6);
write('3. Menghitung M x N Menggunakan Operator +');
gotoxy(3,7);
write('4. Menentukan Barisan Fibbonancy');
gotoxy(3,8);
write('0. Keluar');
gotoxy(3,10);
write('Pilihan Anda {0-4} : ');readln(pilihan);
{validasi menu pilihan}
while(pilihan < 0) or (pilihan > 4) do
begin
gotoxy(27,10);textcolor(RED);
write('Salah Memilih Menu..Ulangi!');
gotoxy(27,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
gotoxy(27,11);clreol;gotoxy(24,10);clreol;
readln(pilihan);
end;
case (pilihan) of
1 : begin
clrscr;
gotoxy(19,2);write('Menghitung Faktorial');
gotoxy(19,3);write('====================');
gotoxy(10,4);
write('Masukan Harga N = ');readln(n);
{validasi harga n}
while(n < 0) or (n > 20) do
begin
gotoxy(10,5);textcolor(RED);
write('Harga N antara 0 sampai 20.. Ulangi!');
gotoxy(10,6);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
gotoxy(10,5);clreol;gotoxy(10,6);clreol;
gotoxy(28,4);clreol;
textcolor(0);readln(n);
end;
if(n=0) or (n=1)
then
faktorial:=1
else
begin
faktorial:=n;
for i:= (n-1) downto 2 do
faktorial:=faktorial*i;
end;
gotoxy(10,5);
write('Faktorial dari ',n,' = ');
textcolor(RED);write(faktorial:0:0);
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
2 : begin
clrscr;
gotoxy(5,5);
write('Menentukan Suku ke-N dari Barisan : 3,6,9,36..');
gotoxy(5,6);
write('==============================================');
gotoxy(5,7);
write('Masukan Harga N : ');readln(n);
if(n=1)
then
suku:=3
else
begin
suku:=3;
for i := 2 to n do
begin
if(i mod 2=0)
then
suku := suku * i
else
suku := suku + i
end;
end;
gotoxy(5,8);
write('Suku ke-',n,' : ');
textcolor(RED);write(suku);
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
3 : begin
clrscr;
gotoxy(9,2);write('Menghitung M x N menggunakan operator +');
gotoxy(9,3);write('=======================================');
gotoxy(5,4);
write('Masukan harga M = ');readln(m);
gotoxy(5,5);
write('Masukan harga N = ');readln(n);
if(m=0)or(n=0)
then
kali:=0
else
if(m<0)or(m>0)and(n>0)
then
kali:=m;
for i:=2 to n do
kali:=kali+m;
if (m>0) and(n<0)
then
begin
kali:=n;
for i:=2 to n do
kali:= kali+n;
begin
x := -m;
y := -n;
kali := x;
for i := 2 to y do
kali := kali +x;
end;
end;
gotoxy(5,6);
write(m,' x ',n,' = ');textcolor(RED);
write (kali);
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
4 : begin
clrscr;
gotoxy(15,2);write('Menentukan Barisan Fibbonancy');
gotoxy(15,3);write('=============================');
gotoxy(5,5);
write('Masukkan nilai a = ');readln(a);
gotoxy(5,6);
write('Masukkan nilai b = ');readln(b);
c := 0;
gotoxy(5,7);
write('Masukkan banyaknya angka : ');
readln(n);
gotoxy(5,8);write('Deret Fibonacci : ',a,' ',b,' ');textcolor(RED);
for i := 1 to n do
begin
c := a + b;
a := b;
b := c;
write(c, ' ');textcolor(RED);
end;
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
end;
until(pilihan = 0);
end.
uses crt;
var
pilihan : byte;
n,i,suku,m,o : integer;
faktorial: real;
a,b,c: integer;
kali,x,y: integer;
begin
repeat
clrscr;textcolor(0);
textbackground(BLUE);clrscr;
window(12,7,68,19);textbackground(CYAN);clrscr;
gotoxy(23,2);write('MENU PILIHAN');
gotoxy(23,3);write('============');
gotoxy(3,4);
write('1. Menghitung Faktorial');
gotoxy(3,5);
write('2. Menentukan Suku ke-N dari Barisan : 3,6,9,36..');
gotoxy(3,6);
write('3. Menghitung M x N Menggunakan Operator +');
gotoxy(3,7);
write('4. Menentukan Barisan Fibbonancy');
gotoxy(3,8);
write('0. Keluar');
gotoxy(3,10);
write('Pilihan Anda {0-4} : ');readln(pilihan);
{validasi menu pilihan}
while(pilihan < 0) or (pilihan > 4) do
begin
gotoxy(27,10);textcolor(RED);
write('Salah Memilih Menu..Ulangi!');
gotoxy(27,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
gotoxy(27,11);clreol;gotoxy(24,10);clreol;
readln(pilihan);
end;
case (pilihan) of
1 : begin
clrscr;
gotoxy(19,2);write('Menghitung Faktorial');
gotoxy(19,3);write('====================');
gotoxy(10,4);
write('Masukan Harga N = ');readln(n);
{validasi harga n}
while(n < 0) or (n > 20) do
begin
gotoxy(10,5);textcolor(RED);
write('Harga N antara 0 sampai 20.. Ulangi!');
gotoxy(10,6);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
gotoxy(10,5);clreol;gotoxy(10,6);clreol;
gotoxy(28,4);clreol;
textcolor(0);readln(n);
end;
if(n=0) or (n=1)
then
faktorial:=1
else
begin
faktorial:=n;
for i:= (n-1) downto 2 do
faktorial:=faktorial*i;
end;
gotoxy(10,5);
write('Faktorial dari ',n,' = ');
textcolor(RED);write(faktorial:0:0);
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
2 : begin
clrscr;
gotoxy(5,5);
write('Menentukan Suku ke-N dari Barisan : 3,6,9,36..');
gotoxy(5,6);
write('==============================================');
gotoxy(5,7);
write('Masukan Harga N : ');readln(n);
if(n=1)
then
suku:=3
else
begin
suku:=3;
for i := 2 to n do
begin
if(i mod 2=0)
then
suku := suku * i
else
suku := suku + i
end;
end;
gotoxy(5,8);
write('Suku ke-',n,' : ');
textcolor(RED);write(suku);
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
3 : begin
clrscr;
gotoxy(9,2);write('Menghitung M x N menggunakan operator +');
gotoxy(9,3);write('=======================================');
gotoxy(5,4);
write('Masukan harga M = ');readln(m);
gotoxy(5,5);
write('Masukan harga N = ');readln(n);
if(m=0)or(n=0)
then
kali:=0
else
if(m<0)or(m>0)and(n>0)
then
kali:=m;
for i:=2 to n do
kali:=kali+m;
if (m>0) and(n<0)
then
begin
kali:=n;
for i:=2 to n do
kali:= kali+n;
begin
x := -m;
y := -n;
kali := x;
for i := 2 to y do
kali := kali +x;
end;
end;
gotoxy(5,6);
write(m,' x ',n,' = ');textcolor(RED);
write (kali);
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
4 : begin
clrscr;
gotoxy(15,2);write('Menentukan Barisan Fibbonancy');
gotoxy(15,3);write('=============================');
gotoxy(5,5);
write('Masukkan nilai a = ');readln(a);
gotoxy(5,6);
write('Masukkan nilai b = ');readln(b);
c := 0;
gotoxy(5,7);
write('Masukkan banyaknya angka : ');
readln(n);
gotoxy(5,8);write('Deret Fibonacci : ',a,' ',b,' ');textcolor(RED);
for i := 1 to n do
begin
c := a + b;
a := b;
b := c;
write(c, ' ');textcolor(RED);
end;
gotoxy(15,11);textcolor(15);
write('Tekan Enter untuk Melanjutkan');
readln;
end;
end;
until(pilihan = 0);
end.
Post a Comment