Question: Write a program in C++ language that figures change. Input the amount of a purchase and the amount tendered (given in payment) and determine the

Write a program in C++ language that figures change. Input the amount of a purchase and the amount tendered (given in payment) and determine the change the customer is to receive.Display the change as dollars, quarters, dimes, nickels, and pennies. For example (users input is bold):

Enter the purchase amount: 42.27

Enter the amount tendered: 100.00

Your change is $57.73.

57 dollars, 2 quarters, 2 dimes, 0 nickels, and 3 pennies.

Hints: Since real numbers are not always stored exactly in a computer, after subtract-ing the amount tendered from the purchase price, youll need to round the amount of change to the nearest penny. Do this by adding one-half cent (0.005) to the amount.Next, extract the dollars and cents from the amount of change by setting two integer variables equal to these two values. Getting the number of dollars is easy; just assign the amount to an integer variable. Getting the number of cents is a bit tougher. There are many ways to do this; one way is to multiply the amount of change by 100 (* 100)and then take the remainder when dividing by 100 (% 100).After separating the dollars and cents, output them (for example,57 dollars and 73cents). Get this part working correctly before you try to figure the number of quarters, dimes, etc. Once you have the number of cents of change in an integer variable, figuring the number of each coin is not too bad if you use%(modulo, a.k.a, remainder) and integer division.Start with the highest denomination (quarters) and work your way down.

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 Databases Questions!