Soal 1: Algoritma Penentuan Grade Nilai (Huruf Mutu) Mahasiswa program nilai_mahasiswa deklarasi: nilai : integer grade : char algoritma: write ('Nilai Mahasiswa: ') readln(nilai) if (nilai >= 85) then grade ← 'A' else if (nilai >= 75) and (nilai < 85) then grade ← 'B' else if (nilai >= 60) and (nilai < 75) then grade ← 'C' else if (nilai >= 45) and (nilai < 60) then grade ← 'D' else grade ← 'E' endif endif endif endif write('Nilai Huruf Mutu: ', grade)
Translasi Ke Code Pascal: Program nilai_mahasiswa; Uses crt; Var nilai : integer; grade : char; Begin
Clrscr; write('Nilai Mahasiswa: '); readln(nilai); if (nilai >= 85) then grade:='A' else if (nilai >= 75) and (nilai < 85) then grade:='B' else if (nilai >= 60) and (nilai < 75) then grade:='C' else if (nilai >= 45) and (nilai < 60) then grade:='D' else grade:='E; write('Nilai Huruf Mutu: ', grade);
End.
Soal 2: Algoritma Perhitungan Pajak Bangunan program pajak_bangunan const hargajual ← 50000 deklarasi: p, l, luas : real totpajak, pajak : real tothargajual : real algoritma: write('Panjang Tanah: ') read(p) write('Lebar Tanah: ') read(l) luas ← p*l if (luas >= 500) then pajak ← 0.1 else pajak ← 0.05 endif tothargajual ← luas * hargajual totpajak ← pajak * tothargajual write('Luas Tanah: ', luas) write('Total Pajak: ', totpajak)
Translasi Ke Code Pascal: Program pajak_bangunan; Uses crt; const hargajual1=50000; hargajual2=100000; Var p, l, luas, totpajak, pajak, tothargajual: real; Begin
Clrscr; Writeln(' Entry Data Pajak '); Writeln('====================================='); Writeln; Write('Panjang : ');Readln(p); Write('Lebar : ');Readln(l); Writeln; luas := p*l; if luas >= 500 then pajak := 0.1 else pajak := 0.05; tothargajual := luas*hargajual1; totpajak := tothargajual*pajak;
Writeln('====================================='); Writeln; Writeln('Luas Tanah : ',luas:10:0,' m2'); Writeln('Total Harga Jual : Rp.',tothargajual:10:0); Writeln('Total Pajak : Rp.',totpajak:10:0); Writeln; Writeln('====================================='); Readln; End.
Soal 3: Algoritma Penggajian Pegawai Program gaji_karyawan Deklarasi: nip, gol nama, status masakerja, gapok, jmlanak tjistri, tjanak, jamker, galem gatot, kasbon, gaber, jamlem, lembur Algoritma: Write('NIP Write('Nama Write('Golongan Write('Jam Kerja write('Masa Kerja write('Status write('Jumlah Anak write('Jum Kasbon
: : : : : : : :
') ') ') ') ') ') ') ')
: : : : :
char string real real real
Readln(nip) Readln(nama) Readln(gol) Readln(jamker) Readln(masakerja) Readln(status) Readln(jmlanak) Readln(kasbon)
if ((gol='I') or (gol='i') or (gol='1')) and (masakerja <= 2) then gapok ← 400000 else if ((gol='I') or (gol='i') or (gol='1')) and (masakerja > 2) then gapok ← 650000 else if ((gol='II') or (gol='ii') or (gol='2')) and (masakerja <= 4) then gapok ← 900000 else gapok ← 1200000 endif endif endif if ((status='menikah') or (status='MENIKAH')) and (jmlanak <= 3) then { tjistri ← 0.25*gapok tjanak ← 50000*jmlanak } else if ((status='menikah') or (status='MENIKAH')) and (jmlanak > 3) then { tjistri ← 0.25*gapok tjanak ← 150000 } else { tjistri ← 0 tjanak ← 0 } endif endif if (jamker > 160) then { jamlem ← jamker-160 lembur ← 5000 } galem ← jamlem*lembur gatot ← gapok+tjistri+tjanak+galem gaber ← gatot-kasbon Writeln(nama) Writeln('Gaji Lemburan : Rp.',galem) Writeln('Total Gaji Keseluruhan : Rp.',gatot) Writeln('Gaji Bersih Pegawai : Rp.',gaber)
Translasi Ke Code Pascal: Program gaji; Uses crt; Var nip, gol nama, status masakerja, gapok, jmlanak tjistri, tjanak, jamker, galem gatot, kasbon, gaber, jamlem, lembur
: : : : :
char; string; real; real; real;
Begin Clrscr; Writeln(' Entry Gaji Pegawai PT. XYZ '); Writeln('=========================================='); Writeln; Write('NIP : ');Readln(nip); Write('Nama : ');Readln(nama); Write('Golongan : ');Readln(gol); Write('Jam Kerja : ');Readln(jamker); write('Masa Kerja : ');Readln(masakerja); write('Status : ');Readln(status); write('Jumlah Anak : ');Readln(jmlanak); write('Jum Kasbon : ');Readln(kasbon); Writeln; if ((gol='I') or (gol='i') or (gol='1')) and (masakerja <= 2) then gapok := 400000 else if ((gol='I') or (gol='i') or (gol='1')) and (masakerja > 2) then gapok := 650000 else if ((gol='II') or (gol='ii') or (gol='2')) and (masakerja <= 4) then gapok := 900000 else gapok := 1200000; if ((status='menikah') or (status='Menikah') or (status='MENIKAH')) and (jmlanak <= 3) then begin tjistri:=0.25*gapok; tjanak:=50000*jmlanak; end else if ((status='menikah') or (status='Menikah') or (status='MENIKAH')) and (jmlanak > 3) then begin tjistri:=0.25*gapok; tjanak:=3*50000; end else begin tjistri:=0; tjanak:=0; end; if (jamker > 160) then begin jamlem := jamker-160; lembur := 5000; end; galem := jamlem*lembur; gatot := gapok+tjistri+tjanak+galem; gaber := gatot-kasbon; Writeln('=========================================='); Writeln(nama:12); Writeln; Writeln('Gaji Lemburan : Rp.',galem:12:0); Writeln('Total Gaji Keseluruhan : Rp.',gatot:12:0); Writeln('Gaji Bersih Pegawai : Rp.',gaber:12:0); Readln; End.
Soal 4: Algoritma Rental Mobil program rental const pajak=0.1 deklarasi: kode : char kelas : string harga, lama : integer diskon, hartot, jmltiket, tagihan : real algoritma: write('Kode Rental: ') read(kode) write('Jumlah Tiket: ') read(jmltiket) write('Lama Sewa: ') read(lama) if (kode='S') then if (lama >= 3) then kelas ← 'sedan' harga ← 500000 diskon ← 0.2 * harga else kelas ← 'sedan' harga ← 500000 diskon ← 0 endif else if (kode='M') then kelas ← 'minibus' harga ← 300000 diskon ← 0 else kelas ← 'bus' harga ← 1200000 diskon ← 0 endif endif hartot ← jmltiket * (harga + pajak*harga) tagihan ← hartot - diskon write(kelas) write(hartot) write(diskon) write(tagihan)