Question: Using c++ Example Runs Enter purchase amount: 18.89 Enter amount received: 20.00 Total change: $1.11 dollars 1 quarters 0 dimes 1 nickels 0 Pennies 1
Assignment: Cash Register Your goal is 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 quantities of each monetary denomination to arrive at that change amount. Finally, the program should output the total change followed by how many of each type of currency to give back to the customer. Algorithm outline: Calculate the change in dollars, then convert it to pennies, assigning this number into a new variable. Then use integer division to calculate 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 casting: specifically, we use an operator called a static cast as follows: int variable static_cast
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
