RSS

ATM sederhana

program atm_bersama
uses wincrt;
 
var uang : longint;
 
begin
  write('Nilai uang : ');readln(uang);
 
  if uang div 100000 > 0 then begin
    writeln(uang div 100000, ' lembar seratus ribuan');
    uang := uang mod 100000;
  end;
 
  if uang div 50000 > 0 then begin
    writeln(uang div 50000, ' lembar lima puluh ribuan');
    uang := uang mod 50000;
  end;
 
  if uang div 20000 > 0 then begin
    writeln(uang div 20000, ' lembar dua puluh ribuan');
    uang := uang mod 20000;
  end;
 
  if uang div 10000 > 0 then begin
    writeln(uang div 10000, ' lembar sepuluh ribuan');
    uang := uang mod 10000;
  end;
 
  if uang div 5000 > 0 then begin
    writeln(uang div 5000, ' lembar lima ribuan');
    uang := uang mod 5000;
  end;
 
  if uang div 1000 > 0 then begin
    writeln(uang div 1000, ' lembar ribuan');
    uang := uang mod 1000;
  end;
 
  if uang div 500 > 0 then begin
    writeln(uang div 500, ' lembar lima ratusan');
    uang := uang mod 500;
  end;
 
  if uang div 100 > 0 then begin
    writeln(uang div 100, ' ratusan');
    uang := uang mod 100;
  end;
 
  if uang div 50 > 0 then begin
    writeln(uang div 50, ' limapuluhan');
    uang := uang mod 50;
  end;
 
  if uang > 0 then begin
    writeln(uang, ' satuan');
  end;
 
end.

Mencari Invers dan Determinan pada Pascal

program matriks;
uses wincrt;
var a,b,c,d,i,invers,p,q,r,s:real;

begin
writeln('Mencari Invers Matriks Ordo 2x2 ');
gotoxy(5,5);write('a=');read(a);
gotoxy(18,5);write('b=');read(b);
gotoxy(5,7);write('c=');read(c);
gotoxy(18,7);write('d=');read(d);
D := a*d - b*c;
writeln('Det(A) = ',D);
i:=(a*d)-(b*c);
if not(i=0) then
begin
invers:=1/((a*d)-(b*c));
p:=d*invers;
q:=-b*invers;
r:=-c*invers;
s:=a*invers;
gotoxy(5,10);writeln('Invers matriks A =');
gotoxy(5,13);write(p:0:3);
gotoxy(18,13);write(q:0:3);
gotoxy(5,16);write(r:0:3);
gotoxy(18,16);write(s:0:3);
end
else
begin
gotoxy(25,15);
writeln('Tidak ada invers matriks');
end;
end.

Deret Angka pada Pascal

"deret"
1
2 3
4 5 6
7 8 9 10

program pelajar;
uses wincrt;
var
n,i,j:integer;
begin
n:=1;
for i:=1 to 4 do
    begin
         for j:=1 to i do
         begin
         write(n,' ');
         n:=n+1;
         end;
         writeln(' ');
         end;
end.

Menentukan Nilai IP dengan Pascal

Ini nih bagaimana cara mudah menghitung IP kita menggunakan pascal:

program mata_kuliah_PIK_terbaru;
uses wincrt;
var n: integer;
begin
writeln ('menentukan nilai PIK');
readln (n);
if n>100 then writeln ('cek pintere awakmu cak !!')
else if n>80 then writeln ('A')
else if n>75 then writeln ('AB')
else if n>70 then writeln ('B')
else if n>65 then writeln ('BC')
else if n>60 then writeln ('C')
else if n>40 then writeln ('D')
else if n>=0 then writeln ('E')
else writeln('apaan tuh ??');
end.

Program Faktorial

Ini contoh program faktorial
program faktorial;
uses wincrt;
var
n,i:longint;
f:real;
begin
readln(n); f:=1;i:=0;
repeat

i:=i+1;
f:=f*i;
until i=n;
writeln (n, 'faktorial= ',f)
end.