Saturday, January 5, 2013

Algoritma Membaca Nilai Uang Pecahan

Deklarasi Variabel

   jml_uang : longint;
   prb1,rt20000,rt10000,an5000,an1000,an500,an100 : longint;
   prb1x,rt20000x,rt10000x,an5000x,an1000x,an500x,an100x : longint;

Algoritma
  Input ← Jumlah Uang
  Baca (jumlah_uang)

  prb1 ← jml_uang div 50000;
  prb1x ← jml_uang mod 50000;

  rt20000 ← prb1x div 20000;
  rt20000x ← prb1x mod 20000;

  rt10000 ← rt20000x div 10000;
  rt10000x ← rt20000x mod 10000;

  an5000 ← rt10000x div 5000;
  an5000x ← rt10000x mod 5000;

  an1000 ← an5000x div 1000;
  an1000x ← an5000x mod 1000;

  an500 ←an1000x div 500;
  an500x←an100x mod 500;

  an100←an500x div 100;
  an100x ←an500x mod 100;

  OUTPUT (prb1,rt2000,rt10000,an5000,an1000,an500,an100)

0 comments: