Membuat formasi X dengan '*' pada pascal

Berikut saya berikan contoh code untuk membuat formasi X dengan karakter '*', untuk codenya silahkan simak di bawah ini:
begin
     read(n);
     for i:=1 to n do
         begin
              for j:=1 to n do
                  begin
                       if (j=i) or (j=(n-i+1)) then
                          begin
                               write('*');
                          end
                       else
                           write(' ');
                  end;
              writeln;
         end;
end.

Posted by GUS W on 6:40 AM 0 comments

Membuat Program Mengetahui Bilangan Prima Dengan Pascal

program prima;
uses wincrt;
var i,n:integer;
prm: boolean;
begin
write ('masukkan nilai n: ');
read (n);
prm:true;
if (n mod 2 = 0) and (n<>0) then
write (n,' bukan bilangan prima')
else
begin
for i:=2 to n-1 do
begin
if n mod i = 0 then
begin
prm:=false;
end;
end;

if prm=false then
write (n,' bukan bilangan prima')
else
write (n,' bilangan prima');
end;
end.

Posted by GUS W on 8:58 PM 0 comments

Deret Bilangan Sederhana

program ulang;
uses wincrt;
var i,j,n: integer;
begin
write ('masukkan nilai n: ');
read (n);
for i:=n downto 1 do
begin
for j:=n downto n-i+1 do
begin
write (j);
end;
writeln;
end;
end.

Posted by GUS W on 7:46 AM 0 comments

Program Pascal Membuat ATM Sederhana

program ATM;

uses wincrt;

var a,n,srts,lmplh,sisa1,sisa2,dualm,sisa3:integer;

d,saldo:longint;

Kita misalkan PIN yang tersimpan ada 5 buah PIN. Anda dapat memodifikasi nilai dari const tersebut sesuai dengan keinginan anda

const e=1234;

f=4321;

g=5678;

h=8765;

i=7890;

begin

Writeln ('**************************************************************');

Writeln ('==========================>>>Selamat Datang Nasabah<<<========================');

writeln ('***************************************************************');

writeln;

Write ('Silahkan masukkan PIN Anda: ');

Read (a);

if (a<>e) and (a<>f) and (a<>g) and (a<>h) and (a<>i) then

begin

repeat

clrscr;

Writeln ('*****************************************************');

Writeln ('=============>>>Selamat Datang Nasabah<<<================');

writeln ('****************************************************');

writeln;

Writeln ('PIN yang Anda masukkan salah!!!');

write ('Silahkan Masukkan PIN Anda kembali: ');

read (a);

until (a=e) or (a=f) or (a=g) or (a=h) or (a=i);

end;

writeln;

writeln;

writeln (' Selamat PIN Anda benar');

saldo:=500;

writeln ('Saldo anda Rp. ',saldo);

writeln;

writeln;

repeat

writeln (' ****************************');

writeln (' Menu Layanan');

writeln (' ****************************');

Writeln (' 1.Ambil Uang');

Writeln (' 2.Keluar');

writeln ('');

write (' Silahkan masukkan pilihan Anda dengan menekan angka 1 atau 2: ');

read (n);

if n=1 then

begin

clrscr;

Writeln ('****************************************************');

Writeln ('=================>>>Layanan Pengambilan Uang<<======');

writeln ('******************************************************');

writeln;

writeln ( 'Lembar uang yang bisa diambil:');

Writeln ( 'Rp 25,-');

Writeln ( 'Rp 50,-');

Writeln ( 'Rp 100,-');

writeln ('Saldo Anda Sekarang adalah Rp. ',saldo);

repeat

writeln ('Silahkan masukkan banyaknya uang yang akan diambil');

write ('dengan nominal bilangan bulat: Rp. ');

read (d);

writeln;

until (d>0) and (d<=saldo);

if (d>0) and (d<=saldo) then

begin

srts:= d div 100;

sisa1:= d mod 100;

lmplh:= sisa1 div 50;

sisa2:= sisa1 mod 50;

dualm:= sisa2 div 25;

sisa3:= sisa2 mod 25;

writeln (srts,' Lembar Rp 100,-');

writeln (lmplh,' Lembar Rp 50,-');

writeln (dualm,' Lembar Rp 25,-');

writeln ('Sisa uang yang tidak bisa diambil Rp. ',sisa3);

writeln ('');

writeln ('---------------------------------^-------------------------------');

Writeln ('===========~Selamat, Silahkan Ambil Uang Anda~==========');

writeln ('-------------------------------******----------------------------');

writeln ('');

saldo:=saldo-d+sisa3;

end;

end;

until (n=2);

clrscr;

Writeln ('=================================================================');

Writeln ('=========TERIMA KASIH ATAS KUNJUNGANNYA=========');

Writeln ('=================================================================');

Posted by GUS W on 2:12 AM 3 comments

Followers

About Me

My photo
menjalani dengan serius...........