Problem

Write a program that tells what coins to give out for any amount of change from 1 cent to...

Write a program that tells what coins to give out for any amount of change from 1 cent to 99 cents. For example, if the amount is 86 cents, the output would be something like the following:

86 cents can be given as

3 quarter(s) 1 dime(s) and 1 pennyCpennies)

Use coin denominalions of 25 cents (quarters), 10 cenLs (dimes), and 1 cent (pennies). Do not use nickel and half-dollar coins. Your program will use the following function (among others):

void compute_coins( int coin_value, irrt& num, int& amount_left) ;

//Precondition: 0

//Postcondition: num has been set equal to the maximum number //of coins of denomination coin_value cents that can be obtained

 //from amount_left. Additionally, amount_left has been decreased

//by the value of the coins, that is, decreased by //num * coin_value.

For example, suppose the value of the variable amount_left is 86. Then, after the following call, the value of number will be 3 and the value of amount_1eft will be 11 (because if you take 3 quarters from 86 cents, that leaves 11 cents):

compute_coins(2 5, number, amount_left);

Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. (Hint: Use integer division and the % operator to implement this function.)

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT