Kamis, 21 April 2011

Program Pascal ( Barisan & Deret .)

---- created by rahmatovv ----

PROGRAM BARISAN_DAN_DERET;
uses crt;
var

n,i,a,c,m:integer;
un, b,r,S,sn:real;
ULANG : BOOLEAN;
lagi :char;
pilih :integer;
pangkat,temp:real;

begin
ulang :=true;
while ulang do
begin

Clrscr;
window(51,5,10,22);
textbackground(19);textcolor(13);
gotoxy (10,5);writeln('==========================================');
gotoxy (10,6);writeln('| MENU UTAMA |');
gotoxy (10,7);writeln('|========================================|');
gotoxy (10,8);writeln('| |');
gotoxy (10,9);writeln('| 1.BARISAN ARITMATIKA |');
gotoxy(10,10);writeln('| |');
gotoxy(10,11);writeln('| 2.DERET ARITMATIKA |');
gotoxy(10,12);writeln('| |');
gotoxy(10,13);writeln('| 3.BARISAN GEOMETRI |');
gotoxy(10,14);writeln('| |');
gotoxy(10,15);writeln('| 4.DERET GEOMETRI |');
gotoxy(10,16);writeln('| |');
gotoxy(10,17);writeln('| 5.SELESAI |');
gotoxy(10,18);writeln('| |');
gotoxy(10,19);writeln('|========================================|');
gotoxy(10,20);writeln('|========================================|');
gotoxy(10,21);writeln('| PILIH : |');
gotoxy(10,22);writeln('==========================================');
gotoxy(28,21);readln(pilih);

case pilih of
1:begin
lagi := 'Y';
while upcase(lagi)='Y' do
begin
clrscr;


write('masukkan baris suku ke-1 : ');readln(a);
write('masukkan baris suku ke-2 : ');readln(c);
write('masukkan suku ke-n yang dicari : ');readln(n);
b:=c-a;
writeln('jadi bedanya adalah = ',b:4:2);
Un:=a+(n-1)*b;
writeln('jumlah baris bilangan aritmatika suku ke-',n,' adalah= ', Un:4:2);
write(' ISI LAGI (Y/T) : ');readln (lagi);
end;
end;
2:begin
lagi := 'Y';
while upcase(lagi)='Y' do
begin
clrscr;
write(' masukkan baris bilangan suku ke-1 : ');readln(a);
write(' masukkan baris bilangan suku ke-2 : ');readln(c );
write(' masukkan suku yang ke-n dicari : ');readln(n);
b:=c-a;
writeln(' jadi bedanya adalah : ',b:4:2);
Sn:=n/2*(2*a+((n-1)*b));
writeln('jumlah baris bilangan deret aritmatika ke-',n,' adalah= ', Sn:4:2);
write(' ISI LAGI (Y/T) : '); readln (lagi);
end;
end;
3:begin


lagi := 'Y';
while upcase(lagi)='Y' do
begin
clrscr;
write('masukkan barisan geometri suku ke-1 : ');readln(a);
write('masukkan barisan suku ke-2 : ');readln(c );
r:=c/a;

write('masukkan suku ke-n barisan geometri yang dicari: ');readln(n);

m:=n-1;
writeln('jadi rasio adalah = ',r:4:2);
begin
temp:=1;
for i:=1 to m do
begin
temp:= temp * r;
end;
pangkat := temp;

end;


Un:=a*pangkat;
writeln('baris bilangan geometri ke-',n,' adalah= ', Un:4:1);

write(' ISI LAGI (Y/T) : '); readln (lagi);

end;
end;
4:begin
lagi := 'Y';
while upcase(lagi)='Y' do
begin
clrscr;
write('masukkan barisan geometri suku ke-1: ');readln(a);
write('masukkan barisan suku ke-2: ');readln(c );
write('masukkan suku ke-n barisan geometri yang dicari: ');readln(n);
r:=c/a;
writeln('jadi rasio adalah = ',r:4:2);
begin
temp:=1;
for i:=1 to n do
begin
temp:= temp * r;
end;
pangkat := temp;

end;
Sn:=a*(pangkat-1)/(r-1) ;
writeln('jumlah suku ke-',n,' deret geometri adalah= ', Sn:4:2);

write(' ISI LAGI (Y/T) : '); readln (lagi);
end;
end;
5:exit;
end;
end;
end.

1 komentar:

  1. Casino Roll: Casino Roll: 100% Bonus + $10 Free
    No Deposit Bonus Casino 슬롯 머신 게임 Slots! 100% up alltension.com to $10 브라 벗기기 Free! Free Bonus on 해외사이트 the first deposit, plus 100% match up to 스포츠 토토 사이트 $50 on first deposit.

    BalasHapus