Pascal Penjadwalan Job / Proses

LISTING PROGRAM :

Download Klik Disini

Program Penjadwalan_Job;
{adalah program untuk penjadwalan job}

uses crt;

var
job_a, job_b, job_c, job_d, job_e :string[1];
a1, a2, b1, b2, c1, c2, d1, d2, e1, e2 : real;
start_a, start_b, start_c, start_d, start_e : real;
end_a, end_b, end_c,end_d, end_e : real;
late_a, late_b, late_c, late_d, late_e : real;
late_a1, late_b1, late_c1, late_d1, late_e1 : real;
tot_idle, tot_late : real;
lagi : char;

begin
lagi:=’y’;
while (lagi=’y’) or (lagi=’Y’) do

begin
clrscr;
writeln(‘Program Penjadwalan Job’);
writeln;
writeln(‘Dibuat oleh :’);
writeln(‘***********************’);
writeln(‘Nama      : SUJITO’);
writeln(‘NIM       : 350.663.018’);
writeln(‘Jurusan   : SI’);
writeln(‘***********************’);
writeln;
writeln(‘JUMLAH JOB   : 5’);
writeln;
writeln(‘Input Job Ke-1’);
writeln(‘——————-‘);
write(‘Nama Job       : ‘); readln(job_a);
write(‘Time           : ‘); readln(a1);
write(‘Due Date       : ‘); readln(a2);

writeln;
writeln(‘Input Job Ke-2’);
writeln(‘——————-‘);
write(‘Nama Job       : ‘); readln(job_b);
write(‘Time           : ‘); readln(b1);
write(‘Due Date       : ‘); readln(b2);

writeln;
writeln(‘Input Job Ke-3’);
writeln(‘——————-‘);
write(‘Nama Job       : ‘); readln(job_c);
write(‘Time           : ‘); readln(c1);
write(‘Due Date       : ‘); readln(c2);

writeln;
writeln(‘Input Job Ke-4’);
writeln(‘——————-‘);
write(‘Nama Job       : ‘); readln(job_d);
write(‘Time           : ‘); readln(d1);
write(‘Due Date       : ‘); readln(d2);

writeln;
writeln(‘Input Job Ke-5’);
writeln(‘——————-‘);
write(‘Nama Job       : ‘); readln(job_e);
write(‘Time           : ‘); readln(e1);
write(‘Due Date       : ‘); readln(e2);

begin
start_a := 0;
end_a:= start_a+a1;
late_a := a2-end_a;

start_b := end_a;
end_b:= start_b+b1;
late_b := b2-end_b;

start_c := end_b;
end_c:= start_c+c1;
late_c := c2-end_c;

start_d := end_c;
end_d:= start_d+d1;
late_d := d2-end_d;

start_e := end_d;
end_e:= start_e+e1;
late_e := e2-end_e;

//menghitung total idle
tot_idle := (start_a+start_b+start_c+start_d+start_e);

//mengidentifikasi nilai late tiap job, hanya nila minus yang diambil
if late_a<0 then {jika minus maka ambil nilai late}
begin
late_a1:=late_a;
end
else             {jika plus maka nol-kan nilai late}
begin
late_a1:=0;
end;

if late_b<0 then
begin
late_b1:=late_b;
end
else
begin
late_b1:=0;
end;

if late_c<0 then
begin
late_c1:=late_c;
end
else
begin
late_c1:=0;
end;

if late_d<0 then
begin
late_d1:=late_d;
end
else
begin
late_d1:=0;
end;

if late_e<0 then
begin
late_e1:=late_e;
end
else
begin
late_e1:=0;
end;

//menghitung total late
tot_late := (late_a1+late_b1+late_c1+late_d1+late_e1);

//menampilkan hasil penjadwalan
clrscr;
writeln;
writeln(‘PROSES PENJADWALAN’);
writeln;
writeln(‘URUT START DUR   END    DD  LATE’);
writeln(‘——————————–‘);
writeln(job_a, start_a:6:0, a1:6:0, end_a:6:0, a2:6:0, late_a:6:0);
writeln;
writeln(job_b, start_b:6:0, b1:6:0, end_b:6:0, b2:6:0, late_b:6:0);
writeln;
writeln(job_c, start_c:6:0, c1:6:0, end_c:6:0, c2:6:0, late_c:6:0);
writeln;
writeln(job_d, start_d:6:0, d1:6:0, end_d:6:0, d2:6:0, late_d:6:0);
writeln;
writeln(job_e, start_e:6:0, e1:6:0, end_e:6:0, e2:6:0, late_e:6:0);
writeln(‘——————————–‘);

writeln;
writeln(‘HASIL AKHIR’);
writeln(‘========================’);
writeln(‘Total Idle Time : ‘,tot_idle:6:2);
writeln(‘Total Late      : ‘,tot_late:6:2);
writeln(‘========================’);

end;

writeln;
write(‘Mau coba lagi ? [y/t] ‘);
readln(lagi);
end;
end.

Kode Pascal Perkalian Matriks

program perkalian_matriks;
uses crt;

const n_i=2;
n_j=2;
n_k=1;

var
A: array [1..n_i,1..n_j] of integer;
B: array [1..n_j,1..n_k] of integer;
C: array [1..n_i,1..n_k] of integer;
i,j,k:integer;
begin
clrscr;
writeln(‘penetapan nilai matriks A’);

for i:=1 to n_i do
for j:=1 to n_j do
begin

write(‘baris ke-‘,i,’kolom ke-‘,j,’ :’);
readln(A[i,j]);
end;

writeln(‘penetapan nilai matriks B’);

for j:=1 to n_j do
for k:=1 to n_k do
begin

write(‘baris ke-‘,j,’kolom ke-‘,k,’ :’);
readln(B[j,k]);
end;
writeln(‘Perhitungsn sedang dilakukan ..’);
for i:= 1 to n_i do
for k:= 1 to n_k do
begin
C[i,k] :=0;

for j:= 1 to n_j do
C[i,k] := C[i,k]+A[i,j] * B[j,k];
end;
writeln(‘Maka nilai matriks C’);

for i:=1 to n_i do
begin
for k:=1 to n_k do
write(C[i,k]:4);
writeln;

end;

readln;
end.

Kode Pascal Penjumlahan Matrik

program penjumlahan_matrik;

uses crt;

const
j_baris=2;
j_kolom=2;

var
a,b,c : array[1..j_baris,1..j_kolom] of integer;
baris, kolom : integer;

begin
clrscr;
color_background(white);
textcolor(blue);
writeln(‘Penetapan nilai matrik A’);
for baris:=1 to j_baris do
for kolom:=1 to j_kolom do begin
write(‘Baris ke-‘,baris,’ Kolom ke-‘,kolom,’:’);
readln(A[baris,kolom]);
end;

textcolor(red);
writeln(‘Penetapan nilai matrik B’);
for baris:=1 to j_baris do
for kolom:=1 to j_kolom do begin
write(‘Baris ke-‘,baris,’ Kolom ke-‘,kolom,’:’);
readln(B[baris,kolom]);
end;

textcolor(green+blink);
writeln(‘Perhitungan sedang dilakukan’);
for baris:=1 to j_baris do
for kolom:=1 to j_kolom do begin
C[baris,kolom]:= A[baris,kolom]+B[baris,kolom];
end;

textcolor(yellow);
writeln(‘Nilai matrik C’);
for baris:=1 to j_baris do begin
for kolom:=1 to j_kolom do
write(C[baris,kolom]);
writeln;
end;
readln;
end.

Kode Pascal Menampilkan Bilangan Genap

Berikut ini adalah contoh pengulangan while .. do dalam bahasa pascal.

Program Pengulangan;

{program pengulangan menggunakan (while – do)
tampilkan Bilangan GENAP
kerjakan aksi SELAMA kondisi terpenuhi yaitu i<50
proses akan berhenti ketika nilai akhir i=49
}            

uses wincrt; {ganti dengan uses crt; jika menggunakan compiler free pascal}

var
     i : integer;
 
Begin                               
     clrscr;
     i := 0;
     while ( i<50 )
     do
       begin
         i := i+2;
         write(‘ ‘,i);  
       end;
       readln;
end.

Kode Pascal Menampilkan Bilangan Ganjil

Berikut ini contoh bahasa Pascal untuk kasus pengulangan menggunakan:  repeat .. until

Program pengulangan;

{program pengulangan menggunakan Repeat – Until
menampilkan bilangan ganjil
kerjakan aksi SAMPAI kondisi terpenuhi yaitu i>50
proses akan berhenti ketika nilai akhir i=51
}

uses wincrt; {ganti dengan uses crt; jika menggunakan compiler free pascal}

var
     i:integer;
 
Begin                               
     clrscr;
     i:=1;
     repeat
        write(‘ ‘,i);
        i:=i+2;
     until(i>50);
        readln;
end.

Kode Pascal Menghitung Gaji (case .. of)

Program Penggajian_Case;
{adalah program untuk menghitung gaji: CASE}

uses wincrt;

var
     no_induk: string[10];
     nama    : string[20];
     kd_status, jml_anak : integer;
     g_pokok, t_gaji, tj, tj_istri, tj_anak: real;
 
Begin
     clrscr;
     writeln(‘Sistim Perhitungan Gaji pakai CASE  :’);
     write(‘Nomor Induk Pegawai  :’); readln(no_induk);
     write(‘Nama                 :’); readln(nama);
     write(‘Gaji Pokok           :’); readln(g_pokok);
     write(‘Status Perkawinan    :’); readln(kd_status);

        case kd_status of
             1: begin  {kawin}
                   tj_istri:=0.1*g_pokok;
                   write(‘Jumlah Anak :’); readln(jml_anak);
                   tj_anak:=jml_anak*(0.05*g_pokok);
                end;

             2: begin {belum kawin}
                   tj_istri:=0;
                   tj_anak:=0;
                end;

             3: begin {cerai}
                   tj_istri:=0;
                   write(‘Jumlah Anak :’); readln(jml_anak);
                   tj_anak:=jml_anak*(0.05*g_pokok);
                end;                                               
             else begin
                  writeln(‘Status tidak ada …!;’);
             end;
        end;
        tj:=tj_istri+tj_anak;
        t_gaji:=g_pokok+tj;
        write(‘Jumlah Gaji :’,t_gaji:8:2);
        readln;
end.   

Kode Pascal Hitung Lembur (Case .. of)

Program Penggajian;
{contoh algoritma pascal untuk menghitung upah dan lembur: mengunakan CASE .. OF}

uses crt;

var
     nama    : string[20];
     gol         : integer;
     jam, jam_lembur, g_tetap, g_lembur, t_gaji : real;
 
Begin                               
     clrscr;
     writeln(‘Sistim Perhitungan Gaji:’);
     writeln;
     write(‘Nama Karyawan      : ‘); readln(nama);
     write(‘Golongan                   : ‘); readln(gol);
     write(‘Jumlah Jam Kerja   : ‘); readln(jam);
     writeln;

     if jam<=145 then
        begin
            jam_lembur:=0;
        end
     else
        begin
            jam_lembur:=jam-145;
        end;
    
        case gol of
             1: begin  {golongan 1}
                  g_tetap:=500000;
                  g_lembur:=jam_lembur*(5000*1.5)
                end;

             2: begin {golongan 2}
                   g_tetap:=300000;
                   g_lembur:=jam_lembur*(3000*1.5)
                end;

             3: begin {golongan 3}
                   g_tetap:=250000;
                   g_lembur:=jam_lembur*(2000*1.5)
                end;

             4: begin {golongan 4}
                   g_tetap:=100000;
                   g_lembur:=jam_lembur*(1500*1.5)
                end;

             5: begin {golongan 5}
                   g_tetap:=50000;
                   g_lembur:=jam_lembur*(1000*1.5)
                end;

        else
             begin
                writeln(‘Golongan tidak ada, data tidak bisa diproses …!;’);
                writeln;
             end;
     end;                    
        writeln(‘Gaji tetap         : ‘,g_tetap:12:2);
        writeln(‘Lembur             : ‘,g_lembur:12:2);
        writeln(‘———————————+’);
        writeln(‘Total Gaji         : ‘,g_tetap+g_lembur:12:2);
        readln;
end.