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.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s