I have written the code for the following problem but, I need help to fix functi
ID: 3625030 • Letter: I
Question
I have written the code for the following problem but, I need help to fix function make_change using call by reference (see below).
Problem
Write a program that tells what coins to give out for any amount of change from 1 cent to 99 cents. You should use one function called get_input, to get the input from the user and another function called make_change that uses a call-by-reference mechanism to “pass back” how many quarters, dimes, nickels and pennies are needed.
(Note you need to get 4 answers and Do not use Global variables)
You should write a third function called display_results to actually do the printing to the screen. You may write other functions as well, if you like.
For example if the amount is 86 cents, then the input would be 86 and the output would be something like the following:
86 cents can be given as
3 quarters, 1 dime, 0 nickels and 1 penny
If it were 31 cents, your output should look like
31 cents can be given as
1 quarter, 0 dimes, 1 nickel and 1 penny
CODE
#include
using namespace std;
void get_value(int coin_value, int &number, int &make_change);
void input(int &make_change);
void display_results(int &make_change);
int main()
{
int make_change;
int number;
char choice;
do
{
input(make_change);
display_results(make_change);
cout<<"Would you like to run again? (Y/N)? ";
cin>>choice;
}
while (choice=='Y' || choice=='y');
return 0;
}
void get_value(int coin_value, int &number, int &make_change)
{
number = make_change/coin_value;
make_change = make_change%coin_value;
}
void input( int &make_change)
{
cout<<"Coins ";
cin>>make_change;
}
void display_results (int &make_change)
{
int number;
get_value(25, number, make_change);
cout<
get_value(10, number,make_change);
cout<
get_value (05, number, make_change);
cout<
cout<
}