Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
C++
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 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started