Exersices 4

Dosen : Elisawati, S.Kom, M.Kom

Buatlah program tampilan di bawah ini dengan menggunakan prosedure :

  • Nama Kasir : Input

  • Nama Barang : Input

  • Jumlah Barang : Input

  • Harga Barang : Input

  • Total Harga : output (Jumlah Barang * Harga Barang)

  • Discount : Output (Didapat dari Total Harga >= 1.000.000 maka discount 5%, selain itu 0)

  • Total Bersih : Output (Total Harga - Discount)

Jawaban :

exersices4.pas
Program Exersices4;
Uses CRT;
procedure proses_algoritma(var a,b : real);

var 
    hasil,discount,total_bersih : real;

begin
    hasil := a*b;
    writeln('Total Harga : ',hasil:0:0);
    if (hasil >= 1000000) then 
        begin
            discount := hasil*5/100;
            total_bersih := hasil - discount;
            writeln('Discount : ', discount:0:0);
            writeln('Total Bersih : ', total_bersih:0:0);
        end;
    
end;

// procedure total(params);
// begin
    
// end;

var
    nb,nk : STRING;
    th,d,tb,jb,hb : REAL;

begin
    clrscr;
    write('Nama Kasir : '); readln(nb);
    write('Nama Barang : '); readln(nk);
    write('Jumlah barang : '); readln(jb);
    write('Harga Barang : '); readln(hb);
    proses_algoritma(jb,hb);
end.

Last updated

Was this helpful?