Question: Using c++ Your goal ls to simulate a cash register. Your program should first ask for the purchase amount and then the amount paid by

Using c++
 Using c++ Your goal ls to simulate a cash register. Your

Your goal ls to simulate a cash register. Your program should first ask for the purchase amount and then the amount paid by the customer. Then the program should calculate the total change and the quantitles of each monetary should output the total change followed by how many of each type of currency to give back to the customer. to arrive at that change amount. Finally, the program Algorithm outline: Calculate the change in dolars, then convert it to pennies,assigning this number into a new voriable. Then use integer division to colculate the number of each coin denomination, and use the modulo operator to update the remaining number of pennies each time. This requires that we convert from floating point data (change in dollars) to integer data (change in pennies), a process called costing: specifically, we use an operator called a static cast as follows int-variable static-cast(int fP-variable ); - We have to be careful about this: It doesn't always glve us the result we expect Since it truncates (rather than rounding), a number such as 46.999999 (which, even displays as 47) will become 46 as an int (go aheod and try it) as a double, To get around this, all we have to do is add Q.S before casting: this will force the fp number to be rounded to the nearest int: x- static castcint>y100 0.5 ) Convince yourself that this does indeed work for any decimall fraction. For this lab esercise, what are good variable names for xand? Run both of the below examples First utilize proper casting with the "rounding" amount as described above. Then run both again without iR. See the difference? Enter purchase anount: 25.36 Enter amount received: 20 00 Enter amount received: 4 Total Change: 2 dollars 24 quarters dines 2 nickela pennies 4 dines 1 nicke:s pennies

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!