Question: Write program that will repeatedly allow the user to determine the change due (the actual number of bills and coins) on a given purchase for

Write program that will repeatedly allow the user to determine the change due (the actual

number of bills and coins) on a given purchase for a specified amount tendered that exceeds the

purchase amount. First, the program calls a function input that will prompt for and read in the

purchase amount and the amount of money tendered by the customer (both in dollars, floating point

values), and then determine the change due in dollars (floating point value) and the number of

dollars and cents in change due (integer values). All five of these values should be "returned" via

reference parameters. Next, the program should determine the fewest number of bills (ones, fives,

tens, and twenties) and coins (pennies, nickels, dimes, and quarters) to return to the customer in

change. To do this, the program must use two functions dollars and coins. Function dollars

should determine the minimum number of bills of each denomination in the change and "return"

these numbers. Function coins should determine the minimum number of coins of each

denomination in the change and "return" these numbers. Next, the program should call a function

display that will display all of these values: The purchase amount, the amount tendered, the

change amount, and the minimum number of bills and coins required to make the change. This

function should not use any reference parameters. And finally, the program should ask if the user

wants to determine another change breakdown, and then continue or stop based on the user

response.

Notes:

The functions that determine the change numbers should "return" the numbers to the

calling module, not display them.

Assume that the only dollar bills used for change will be $20, $10, $5, and $1.

Assume that the only coins used for change will be quarters, dimes, nickels, and pennies.

Hint: Use integer quantities to do the calculations necessary to determine the minimum number of

bills and coins: After calculating the float change due amount, convert the change due into cents,

storing the result in an integer variable. (Note: To avoid floating point rounding issues when making

this conversion, include use of the floor function, as described in Part 4 of the notes, to round the

converted value to the nearest integer - i.e., for a float value x, floor(x+0.5) will return x

rounded to the nearest integer.) Then, use this value, along with the integer division and modulus

operators, to determine the number of dollars and cents in the change, storing these values in integer

variables. Then, use these values, along with the integer division and modulus operators, to

determine the minimum number of bills and coins required to make the change.

DO NOT USE A BREAK STATEMENT!

Here is an example of what output should look like from running your program (user input is shown

in bold):

Enter purchase amount: $100.06

Enter amount tendered: $200

Amount of purchase: $100.06

Amount tendered: $200.00

Change due: $99.94

Bills:

4 - $20's 1 - $10's 1 - $5's 4 - $1's

Coins:

3 - quarter(s) 1 - dime(s) 1 - nickel(s) 4 - penny(ies)

Continue (y or n)? y

Enter purchase amount: $7.89

Enter amount tendered: $10

Amount of purchase: $7.89

Amount tendered: $10.00

Change due: $2.11

Bills:

0 - $20's 0 - $10's 0 - $5's 2 - $1's

Coins:

0 - quarter(s) 1 - dime(s) 0 - nickel(s) 1 - penny(ies)

Continue (y or n)? n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!