#include<iostream> #include <cstdlib> #include <cstring> using namespace std; int kata; char val [100]; int validasi() { do { kata=0; cin>>val; for(int i=0; i<strlen(val); i++) { if(isdigit(val[i])==0) kata++; } if(kata !=0) cout<<"Input salah !\n"<<endl; } while(kata!=0); return 0; } int main() { long int jml,limapuluhribu,duapuluhribu,sepuluhribu; long int limaribu,dua_rb,seribu,limaratus,duaratus,seratus; cout<< "Program Tukar Uang"<<endl; cout<< "-------------------"<<endl; cout<< "Masukkan Jumlah Kembalian = "; validasi(); jml=atoi(val); limapuluhribu=jml/50000; jml=jml%50000; duapuluhribu=jml/20000; jml=jml%20000; sepuluhribu=jml/10000; jml=jml%10000; limaribu=jml/5000; jml=jml%5000; dua_rb=jml/2000; jml=jml%2000; seribu=jml/1000; jml=jml%1000; limaratus=jml/500; jml=jml%500; duaratus=jml/200; jml=jml%200; seratus=jml/100; jml=jml%100; cout<<"----------------"<<endl; cout<<"Rincian Mata Uang"<<endl; cout<<"----------------"<<endl; if(limapuluhribu!=0){ cout<<limapuluhribu<<" lembar 50.000"<<endl; } if(duapuluhribu!=0){ cout<<duapuluhribu<<" lembar 20.000"<<endl; } if(sepuluhribu!=0){ cout<<sepuluhribu<<" lembar 10.000"<<endl; } if(limaribu!=0){ cout<<limaribu<<" lembar 5.000"<<endl; } if(dua_rb!=0){ cout<<dua_rb<<" lembar 2.000"<<endl; } if(seribu!=0){ cout<<seribu<<" lembar 1.000"<<endl; } if(limaratus!=0){ cout<<limaratus<<" koin 500"<<endl; } if(duaratus!=0){ cout<<duaratus<<" koin 200"<<endl; } if(seratus!=0){ cout<<seratus<<" koin 100"<<endl; } }
Subscribe to:
Post Comments
(
Atom
)
0 comments:
Post a Comment