latest Post

Program tukar kembalian menggunakan C++



#include<iostream>
using namespace std;

#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;   
} 

} 

About Unknown

Unknown
Recommended Posts × +

1 comments:

  1. Blackjack Lobby Slot Machine - Mapyro
    Play Blackjack 서귀포 출장안마 Lobby 당진 출장안마 Slot Machine 경주 출장안마 for free at Mapyro. The Blackjack Lobby 양주 출장샵 slot machine was a part of the casino 군산 출장샵 that helped build the

    ReplyDelete