Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to determine what change a cashier should return to a customer. The program will ask how much an item being purchased costs,
Write a program to determine what change a cashier should return to a customer. The program will ask how much an item being purchased costs, and then how much the customer paid. The program will return what change should be given. (see output below) Hint: The change being returned should be mathematically changed to an integer representing the amount in pennies. This will allow you to use integer division and the modulus operator. The output prints the total cents to be returned (which should be an integer variable) to make sure that this step is done correctly. Also, there are times, because it is converting from a decimal number to an integer after doing math with the decimal numbers, there could be a rounding error (the cents to be returned might be off by a penny) To fix this, make the numbers they enter into an integer (multiply them to move the decimal and then store them in integer variables, which will truncate the decimal) BEFORE you subtract. That way you are subtracting 2 integers and not two doubles. PLEASE FOLLOW THIS ADVICE: This program will be challenging. First try to use paper and pencil to calculate each number being output. Then try to think about what variables you used (what numbers did you use to calculate your answers) Then start by just printing the number of cents to be returned. Then try to just print out the number of 10 dollar bills and get that to work. Then add the number of 5 dollar bills and get that to work. Then add the number of 1 dollar bills, etc. In other words, just go down the output, but only do one line of output at a time and get that to work before moving to the next line. By doing each part one at a time, you will start to see a pattern to how to solve this. Sample Output Enter the item cost: 7.12 Enter what customer paid: 20.00 The total number of cents to be returned is: 1288 Change given should be Number of 10 dollar bills: 1 Number of 5 dollar bills: 0 Number of 1 dollar bills: 2 Number of quarters: 3 Number of dimes: 1 Number of nickels: 0 Number of pennies: 3
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