uses wincrt;
var
nm_dpn, nm_tgh, nm_blkg, nm_lgkp:string;
begin
write('Nama Depan :');readln(nm_dpn);
write('Nama Tengah :');readln(nm_tgh);
write('Nama Belakang:');readln(nm_blkg);
writeln;
writeln;
nm_lgkp:=nm_dpn+nm_tgh+nm_blkg;
write(‘Nama Lengkap Adalah :’, nm_lgkp);
end.
Latihan 2
uses wincrt;
begin
write('Hasil 2+2*4: ',2+2*4);
end.
Latihan 3
uses wincrt;
var
a,b,c:integer;
begin
write('Bilangan a: ');readln(a);
write('Bilangan b: ');readln(b);
c:=a+b;
writeln;
writeln;
write('Penjumlahan Bilangan ',a,'*',b,'=',c);
end.
Latihan 4
uses wincrt;
var
a,b,c,d,e:integer;
f:real;
begin
write('Bilangan a: ');readln(a);
write('Bilangan b: ');readln(b);
c:=a+b;
d:=a-b;
e:=a*b;
f:=a/b;
writeln;
writeln;
writeln('Penjumlahan Bilangan ',a,'+',b,'=',c);
writeln('Pengurangan Bilangan ',a,'-',b,'=',d);
writeln('Perkalian Bilangan ',a,'x',b,'=',e);
writeln('Pembagian Bilangan ',a,'/',b,'=',f :6:2);
end.
Lupa latihan ke-brp
uses wincrt;
var
nm_dpn, nm_tgh, nm_blkg, nm_lgkp:string;
begin
write('Nama Depan :');readln(nm_dpn);
write('Nama Tengah :');readln(nm_tgh);
write('Nama Belakang:');readln(nm_blkg);
writeln;
writeln;
nm_blkg:=concat(nm_dpn, nm_tgh, nm_blkg);
write(‘Nama Lengkap Adalah :’, nm_blkg);
end.
Lupa juga yg ini
program contoh;
uses wincrt;
var
nama:string[25];
nilai_akhir:integer;
nilai_rata2:integer;
nilai_huruf:char;
keterangan:string;
begin
(*inputan data*)
write('masukan nama:');readln(nama);
write('masukan nilai akhir:');readln(nilai_akhir);
write('masukan nilai rata-rata:');readln(nilai_rata2);
write('masukan grade:');readln(nilai_huruf);
write('masukan keterangan:');readln(keterangan);
(*tampilan data*)
writeln('nama siswa adalah ',nama);
writeln('nilai akhir adalah ',nilai_akhir);
writeln('nilai rata-rata adalah ',nilai_rata2);
writeln('gradernya adalah ',nilai_huruf);
writeln('keterangan adalah ',keterangan);
end.
Yg ini Tugas
program penjualan;
uses wincrt;
label
atas;
var
mkn, mnm:string;
hrgmkm, nrgmnm, jmlmkm, jmlmnm, total:real;
begin
atas:
write(‘Input kode makanan : ‘);readln(mkn);
write(‘Jumlah beli : ‘);readln(jmlmkm);
write(‘Input kode Minuman : ‘);readln(mnm);
write(‘Input beli : ‘);readln(jmlmnm);
if (mkn = ‘bks’) and (mnm= ‘jm’) then
begin
hrgmkm:=10000;
nrgmnm:=6000;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘bks’) and (mnm=’et’) then
begin
hrgmkm:=10000;
nrgmnm:=1500;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘bks’) and (mnm=’ek’) then
begin
hrgmkm:=10000;
nrgmnm:=2500;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘may’) and (mnm=’jm’) then
begin
hrgmkm:=8000;
nrgmnm:=6000;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘may’) and (mnm=’et’) then
begin
hrgmkm:=8000;
nrgmnm:=1500;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘may’) and (mnm=’ek’) then
begin
hrgmkm:=8000;
nrgmnm:=2500;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘lpn’) and (mnm=’jm’) then
begin
hrgmkm:=15000;
nrgmnm:=6000;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘lpn’) and (mnm=’et’) then
begin
hrgmkm:=15000;
nrgmnm:=1500;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else if (mkn= ‘lpn’) and (mnm=’ek’) then
begin
hrgmkm:=15000;
nrgmnm:=2500;
total:=(hrgmkm*jmlmkm)+(nrgmnm*jmlmnm);
writeln(‘Harga Total: ‘,total:2:2);
end
else
begin
writeln(‘Kode yang Anda masukan salah!!!’);
Goto atas;
end
end.
Menu dengan If
uses wincrt;
var
pilih, bil1, bil2, hsl:integer;
begin
writeln('Menu Operasi');
writeln('1. Penjumlahan');
writeln('2. Pengurangan');
writeln('3. Perkalian');
write('Input pilihan Operasi: ');readln(pilih);
if pilih=1 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1+bil2;
writeln(‘Hasil Penjumlahan : ‘,hsl);
end
else if pilih=2 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1-bil2;
writeln(‘Hasil Pengurangan : ‘,hsl);
end
else if pilih=3 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1*bil2;
writeln(‘Hasil Perkalian : ‘,hsl);
end
else
writeln(‘Pilihan Anda Salah!!’);
uses wincrt;
var
pilih, bil1, bil2, hsl:integer;
begin
writeln(‘Menu Operasi’);
writeln(’1. Penjumlahan’);
writeln(’2. Pengurangan’);
writeln(’3. Perkalian’);
write(‘Input pilihan Operasi: ‘);readln(pilih);
if pilih=1 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1+bil2;
writeln(‘Hasil Penjumlahan : ‘,hsl);
end
else if pilih=2 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1-bil2;
writeln(‘Hasil Pengurangan : ‘,hsl);
end
else if pilih=3 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1*bil2;
writeln(‘Hasil Perkalian : ‘,hsl);
end
else
writeln(‘Pilihan Anda Salah!!’);uses wincrt;
var
pilih, bil1, bil2, hsl:integer;
begin
writeln(‘Menu Operasi’);
writeln(’1. Penjumlahan’);
writeln(’2. Pengurangan’);
writeln(’3. Perkalian’);
write(‘Input pilihan Operasi: ‘);readln(pilih);
if pilih=1 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1+bil2;
writeln(‘Hasil Penjumlahan : ‘,hsl);
end
else if pilih=2 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1-bil2;
writeln(‘Hasil Pengurangan : ‘,hsl);
end
else if pilih=3 then
begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1*bil2;
writeln(‘Hasil Perkalian : ‘,hsl);
end
else
writeln(‘Pilihan Anda Salah!!’);
end.
Menu Case
uses wincrt;
var
pilih, bil1, bil2, hsl:integer;
begin
writeln('Menu Operasi');
writeln('1. Penjumlahan');
writeln('2. Pengurangan');
writeln('3. Perkalian');
write('Input pilihan Operasi: ');readln(pilih);
case pilih of
1: begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1+bil2;
writeln(‘Hasil Penjumlahan : ‘,hsl);
end;
2: begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1-bil2;
writeln(‘Hasil Penjumlahan : ‘,hsl);
end;
3: begin
write(‘Bilangan 1: ‘);readln(bil1);
write(‘Bilangan 2: ‘);readln(bil2);
hsl:=bil1*bil2;
writeln(‘Hasil Penjumlahan : ‘,hsl);
end;
end
end.
Tidak ada komentar :
Posting Komentar