write a C++ program that can make change . Your program should take two numbers
ID: 3650434 • Letter: W
Question
write a C++ program that can make change . Your program should take two numbers as input , one that is a monetary amount chargedand the other that is a monetary amount given. It should then return the number of each kind of bill and coin to give back as change for the difference between the amount given and the amount charged . The values assigned to the bills and coins can be based on the monetary system of any current or former government. Try to design your program so that it returns the fewest number of bills and coins as possible .Explanation / Answer
//something I wrote a while back /* write a C++ program that “makes change”. Your program should input two numbers, one that is a monetary amount charged and the other that is a monetary amount given. It should return the number of each kind of bill and coin to give back as change for the difference between the amounts given and changed. The values assigned to the bills and coins can be based on the monetary system of any government. Try to design your program so that it returns the fewest number of bills and coins as possible. */ #include #include using namespace std; /*class CHANGE{ private: double rate[10]={100,50,20,10,5,1,0.25,0.1,0.05,0.01}; //6 bills, 4 coins value double Charged, Given; public : setvalue(double a, double b){ Charged=a;Given=b;} } */ void check(double,double); int main(){ double AmtCharged=0, AmtGiven=0; coutAmtCharged; coutAmtGiven; check(AmtCharged,AmtGiven); cin>>AmtGiven; return 0; } void check(double Charged,double Given){ int rate[10]={10000,5000,2000,1000,500,100,25,10,5,1}; //6 bills, 4 coins value string names[10]={"Hundred-Dollar Bills","Fifty-Dollar Bills","Twenty-Dollar Bills","Ten-Dollar Bills", "Five-Dollar Bills","One-Dollar Bills","Quarters","Dimes","Nickels","Pennies"}; int change[10]={0}, Diff; Diff=(Given-Charged)*100;//to get rid of decimal for cast to integer for(int i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.