Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A. Write a function named change() that has an integer parameter and six integer

ID: 3634163 • Letter: A

Question

A. Write a function named change() that has an integer parameter and six integer reference parameters named hundreds, fifties, twenties, tens, fives, and ones. The function is to consider the passed integer value as a dollar amount and convert the value into the fewest number of equvalent bills. Using the reference parameters, the function should alter the arguments in the calling function.

B. Include the fucntion written in Exercise 4A in a working program. Make sure your function is called from main() correctly. Have main() use a cout statement to display the returned value. Test the fucntion by passing various data to it and verifying the returned value.

Explanation / Answer

#include<iostream>
void change(int amount,int &hundreds,int& fifties,int&twenties,int& tens,int& fives,int& ones)
{

hundreds=amount/100;
amount=amount-
hundreds*100;
fifties=amount/50;
amount=amount-hundreds*50;

twenties=amount/20;
amount=amount-hundreds*20;

tens=amount/10;
amount=amount-hundreds*10;

fives=amount/5;
> }

int main ()
{

int hundreds,fifties,twenties,tens,fives,ones,amount;
cout<<"Enter amount you want change of: ";
cin>>amount;
change(amount,hundreds,fifties,twenties,tens,fives,ones);
cout<<"The change for "<<amount<<" is:"<<endl;
cout<<hundreds<<" hundreds"
<<endl;
cout<<fifties<<" fifties"
<<endl;
cout<<twenties<<" twenties"
<<endl;
cout<<tens<<" tens"
<<endl;
cout<<fives<<" fives"
<<endl;
cout<<ones<<" ones"
<<endl;
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote