Rabu, 06 November 2013

Konversi Uang

Program C++ Konversi Uang


Berkut adalah Source Code untuk mengkonversi jumlah uang yang diinputkan:

#include <iostream.h>
#include <conio.h>

main()
{
    int uang,sisa,sisa2,sisa3,sisa4,sisa5,sisa6,sisa7,sisa8,sisa9,sisa10,
    sisa11,sisa12,sisa13,sisa14,sisa15,sisa16,sisa17,sisa18,sisa19,sisa20;
    cout<<"Masukkan Jumlah Uang= ";cin>>uang;
    sisa=uang/100000;
    sisa2=uang%100000;
    sisa3=sisa2/50000;
    sisa4=sisa2%50000;
    sisa5=sisa4/20000;
    sisa6=sisa4%20000;
    sisa7=sisa6/10000;
    sisa8=sisa6%10000;
    sisa9=sisa8/5000;
    sisa10=sisa8%5000;
    sisa11=sisa10/2000;
    sisa12=sisa10%2000;
    sisa13=sisa12/1000;
    sisa14=sisa12%1000;
    sisa15=sisa14/500;
    sisa16=sisa14%500;
    sisa17=sisa16/200;
    sisa18=sisa16%200;
    sisa19=sisa18/100;
    sisa20=sisa18%100;
   
    cout<<"100.000= "<<sisa<<endl;
    cout<<" 50.000= "<<sisa3<<endl;
    cout<<" 20.000= "<<sisa5<<endl;
    cout<<" 10.000= "<<sisa7<<endl;
    cout<<"  5.000= "<<sisa9<<endl;
    cout<<"  2.000= "<<sisa11<<endl;
    cout<<"  1.000= "<<sisa13<<endl;
    cout<<"    500= "<<sisa15<<endl;
    cout<<"    200= "<<sisa17<<endl;
    cout<<"    100= "<<sisa19<<endl;
    getch();
}