Contoh program konversi uang dengan pascal

program konversiuang_zefy;

uses crt;
var
  nilai : longint;

begin
  writeln('Masukkan Nilai uang yang akan dikonversi: ');
  readln(nilai);

  if nilai div 100000 > 0 then
  begin
    writeln(nilai div 100000,' ==> 100000');
    nilai := nilai mod 100000;
  end; 

  if nilai div 50000 > 0 then
  begin
    writeln(nilai div 50000,' ==> 50000');
    nilai := nilai mod 50000;
  end;

  if nilai div 20000 > 0 then
  begin
    writeln(nilai div 20000,' ==> 20000');
    nilai := nilai mod 20000;
  end;
 
  if nilai div 10000 > 0 then
  begin
    writeln(nilai div 10000,' ==> 10000');
    nilai := nilai mod 50000;
  end;

  if nilai div 5000 > 0 then
  begin
    writeln(nilai div 5000,' ==> 5000');
    nilai := nilai mod 5000;
  end;
 
  if nilai div 2000 > 0 then
  begin
    writeln(nilai div 2000,' ==> 2000');
    nilai := nilai mod 2000;
  end;

  if nilai div 1000 > 0 then
  begin
    writeln(nilai div 1000,' ==> 1000');
    nilai := nilai mod 1000;
  end;

    if nilai div 500 > 0 then
  begin
    writeln(nilai div 500,' ==> 500');
    nilai := nilai mod 2000;
  end;

  if nilai div 200 > 0 then
  begin
    writeln(nilai div 200,' ==> 200');
    nilai := nilai mod 200;
  end;
 
    if nilai div 100 > 0 then
  begin
    writeln(nilai div 100,' ==> 100');
    nilai := nilai mod 100;
  end;

  if nilai div 50 > 0 then
  begin
    writeln(nilai div 50,' ==> 50');
    nilai := nilai mod 50;
  end;

  if nilai div 25 > 0 then
  begin
    writeln(nilai div 25,' ==> 25');
    nilai := nilai mod 25;
  end;

  if nilai div 10 > 0 then
  begin
    writeln(nilai div 10,' ==> 10');
    nilai := nilai mod 10;
  end;
 
  if nilai div 5 > 0 then
  begin
    writeln(nilai div 5,' ==> 5');
    nilai := nilai mod 5;
  end;

  if nilai div 2 > 0 then
  begin
    writeln(nilai div 2,' ==> 2');
    nilai := nilai mod 2;
  end;

  if nilai div 1 > 0 then
  begin
    writeln(nilai div 1,' ==> 1');
    nilai := nilai mod 1;
  end;
  readln;

end.

No comments