Answered step by step
Verified Expert Solution
Question
1 Approved Answer
v Lab Assignment 2: Making Exact Change at Sub Assignment Due Monday by 11:59pm Points 25 Submitting a filc upload In this assignment you will
v
Lab Assignment 2: Making Exact Change at Sub Assignment Due Monday by 11:59pm Points 25 Submitting a filc upload In this assignment you will practice practical control structures. If you can store variables by declaring ints and doubles, perform computations using operators but no built-in math functions, control the order in which statements are created using if to bypass and while ta reverse and perform console I/O with in and cout) then you hasically have all the logical and calculational tools you need to solve almost any problem. While the additional use of functions, arrays, structs.cata structures, recursion, and object-oriented programming makes it easier to write some solutions, they do not really provide any more basic capabilities, so do NOT Use them in this assignment. Arkin point of this assignment is to see if you understand and can deal with round-off error" as discussed in the module reading There's more than one way to do this, so make sure you accommodate it correctly. Background This involves a problem from an annual IBM sponsored ACM Association for Computing Machinery Pacinc North West Regional Programming Contest, a competition among 2 and 4 a -( year colleges from Alaska to Nevada ta Hawaii The solution is not as easy as it might seem. It involves the completion of several complicated steps, and then assembling those steps into a solution. As a programmer, you need to develop the skill to attack a large problem by breaking it down into smaller ones that you can solve. In order to puide you through such a process, this lab assignment is presented in multiple steps. There are 5 separate steps. Follow them carefully, to practice how to develop C++ programs. In the first step you will create a new C++ program file. In the remaining steps, you will add to the hole so that it develops into a complete solution Problem Statement Modern grocery stores now often have a "U Scan" checkout lare, allowing the customer to scan and check out their own graceties, without the need of a human checker. These larves require that change be provided automatically, after the customer sticks their cash in a slut. You are to write a prograin that computes the bills and coins to be dispensed minimizing the total number of bills and coins. That is for change totaling $5.50. You should not dispense 5 ones and 50 pennies, but a $5 bill and a 50-cent plece instead. The bills and coins available for you to dispense are as follows $100 bil, 550 bil, $20 bil, $10 bill $5 bil, $1 bill. 50-tentcoin. 25-tentcoin. 10-tentcoin, 5-cent coin, 1-cent cuin. The console-based program prompts the user to input 2 numbers. The first number is the count of the purchase and the second one is the amount tendered by the customer. You may assume that the amount tendered is greater than or equal to the amount of purchase. The console output wil be a series of lines showing the amount of charge returned and detailing the number of bills and cons that will be dispensed as change in descending order of monetary amount, one unit per line. If a bill/coin is not needed in the change returned, no output is produced for that will/coin In other wanck, da not display "o $1 hils) Plural logic. Proper use of plurals is required, as shown in the sample below. This will require some ir ciselogic to decide whether or not to append an "to the end of a denomination name Hore the sample for a purchase of 42.15, the amount tenderd is so. There are no S or commas in the input just positive real numbers that may or may not contain a decimal. Home is the outout 37.as 1 shill 2 bulls 1 - in 1 25-cent on 1 10 cent coin The program ends normally after the output is produced. Here are some more samples, for a purchase of $13.30 and a tender of $15, and for a 1-cent purchase with a $500 bill: $1.10 . 1 31 btl 1 can coin 2 18-centrins SINI 22 13 bill 220 bills 1 SS LIL 4 $1 hill 1 98-cent coin 1 -cart coin Z le-cent coins 4 1. cum Steps In Software Development STEP 1 of 5: Gerting Started Write your first version of the program with only an empty tnt mot function Name the upp file as you wish Verify that you can comple and run the program which should do nothing! Add your identifying comments and couts with their required library includes), save, compile, and an Again STEP 2 of 5: Collecting Input Add statements to prompt the user for the two numbers purchase amount and amount tendered. Allow the user to enter bath amounts on the same input lines-separated that is. use and do not use cette or cin ignore Verify that you can compile and run the program. STEP 3 of 5: Producing Output Calculate the amount of change returned, and output it with the proper formatting Show the amount with two decimal places, representing cents, and be sure to account for floatire point round of crrors. For example, if the purchase is 1.02, and the amount tendered is 1.10. then the change should be .Dy -- not 0.079999999 and not OLOHUOUD001, and certainly not 0.07 . STEP 4 of 5: Solving The Problem Write the C++ code blocks needed to determine the numbers of hils and coins to dispense in arder to make the corect change. There is no trick Kagic in the US monetary system start with the highest denomination Count out as many of that denomination as needed, one-by-one until the entwining amount falls below the value of the denomination. Then go to the next lower denomination, etc. Do not use functions in this assignment. Do not worry about furmatting of the output at this point -- focus on getting exact results. STEP 5 of 5: Final Formatting Complete the formatting of the results as per the problem statement. Compile and run. Submit the completed CPP. Hints This problem is not as casy as it seems. Be aware of the effects of round-off error, and remember not to test floating point values for exact quality. Remember that with floating point values and computers, 4 minus 2 can often result in 1.9999999999999999 instead of 2, and that is not greater er equal to 2! So instead of asking in an amount is greater than crequal to (for example $50, ask if it's greater than $49.999 no need to check war equal to". That allows for a round affcrrar af as muchas 0.1 cents which is way larger than one would ever expect, but not so large that it would overlap the next cent amount, 549 99. Cashiers salve this problem every day, without using division and dealing with remainders. So your program should be able to solve it too, without divide or modulus and without anath Think about it -- it's not hard "Never assume anything!" Test your program with various input values. Try to break your own program before you give someone else the opportunity to do so Submit your confile for grading and don't forget your identification code blocks! Lab Assignment 2: Making Exact Change at Sub Assignment Due Monday by 11:59pm Points 25 Submitting a filc upload In this assignment you will practice practical control structures. If you can store variables by declaring ints and doubles, perform computations using operators but no built-in math functions, control the order in which statements are created using if to bypass and while ta reverse and perform console I/O with in and cout) then you hasically have all the logical and calculational tools you need to solve almost any problem. While the additional use of functions, arrays, structs.cata structures, recursion, and object-oriented programming makes it easier to write some solutions, they do not really provide any more basic capabilities, so do NOT Use them in this assignment. Arkin point of this assignment is to see if you understand and can deal with round-off error" as discussed in the module reading There's more than one way to do this, so make sure you accommodate it correctly. Background This involves a problem from an annual IBM sponsored ACM Association for Computing Machinery Pacinc North West Regional Programming Contest, a competition among 2 and 4 a -( year colleges from Alaska to Nevada ta Hawaii The solution is not as easy as it might seem. It involves the completion of several complicated steps, and then assembling those steps into a solution. As a programmer, you need to develop the skill to attack a large problem by breaking it down into smaller ones that you can solve. In order to puide you through such a process, this lab assignment is presented in multiple steps. There are 5 separate steps. Follow them carefully, to practice how to develop C++ programs. In the first step you will create a new C++ program file. In the remaining steps, you will add to the hole so that it develops into a complete solution Problem Statement Modern grocery stores now often have a "U Scan" checkout lare, allowing the customer to scan and check out their own graceties, without the need of a human checker. These larves require that change be provided automatically, after the customer sticks their cash in a slut. You are to write a prograin that computes the bills and coins to be dispensed minimizing the total number of bills and coins. That is for change totaling $5.50. You should not dispense 5 ones and 50 pennies, but a $5 bill and a 50-cent plece instead. The bills and coins available for you to dispense are as follows $100 bil, 550 bil, $20 bil, $10 bill $5 bil, $1 bill. 50-tentcoin. 25-tentcoin. 10-tentcoin, 5-cent coin, 1-cent cuin. The console-based program prompts the user to input 2 numbers. The first number is the count of the purchase and the second one is the amount tendered by the customer. You may assume that the amount tendered is greater than or equal to the amount of purchase. The console output wil be a series of lines showing the amount of charge returned and detailing the number of bills and cons that will be dispensed as change in descending order of monetary amount, one unit per line. If a bill/coin is not needed in the change returned, no output is produced for that will/coin In other wanck, da not display "o $1 hils) Plural logic. Proper use of plurals is required, as shown in the sample below. This will require some ir ciselogic to decide whether or not to append an "to the end of a denomination name Hore the sample for a purchase of 42.15, the amount tenderd is so. There are no S or commas in the input just positive real numbers that may or may not contain a decimal. Home is the outout 37.as 1 shill 2 bulls 1 - in 1 25-cent on 1 10 cent coin The program ends normally after the output is produced. Here are some more samples, for a purchase of $13.30 and a tender of $15, and for a 1-cent purchase with a $500 bill: $1.10 . 1 31 btl 1 can coin 2 18-centrins SINI 22 13 bill 220 bills 1 SS LIL 4 $1 hill 1 98-cent coin 1 -cart coin Z le-cent coins 4 1. cum Steps In Software Development STEP 1 of 5: Gerting Started Write your first version of the program with only an empty tnt mot function Name the upp file as you wish Verify that you can comple and run the program which should do nothing! Add your identifying comments and couts with their required library includes), save, compile, and an Again STEP 2 of 5: Collecting Input Add statements to prompt the user for the two numbers purchase amount and amount tendered. Allow the user to enter bath amounts on the same input lines-separated that is. use and do not use cette or cin ignore Verify that you can compile and run the program. STEP 3 of 5: Producing Output Calculate the amount of change returned, and output it with the proper formatting Show the amount with two decimal places, representing cents, and be sure to account for floatire point round of crrors. For example, if the purchase is 1.02, and the amount tendered is 1.10. then the change should be .Dy -- not 0.079999999 and not OLOHUOUD001, and certainly not 0.07 . STEP 4 of 5: Solving The Problem Write the C++ code blocks needed to determine the numbers of hils and coins to dispense in arder to make the corect change. There is no trick Kagic in the US monetary system start with the highest denomination Count out as many of that denomination as needed, one-by-one until the entwining amount falls below the value of the denomination. Then go to the next lower denomination, etc. Do not use functions in this assignment. Do not worry about furmatting of the output at this point -- focus on getting exact results. STEP 5 of 5: Final Formatting Complete the formatting of the results as per the problem statement. Compile and run. Submit the completed CPP. Hints This problem is not as casy as it seems. Be aware of the effects of round-off error, and remember not to test floating point values for exact quality. Remember that with floating point values and computers, 4 minus 2 can often result in 1.9999999999999999 instead of 2, and that is not greater er equal to 2! So instead of asking in an amount is greater than crequal to (for example $50, ask if it's greater than $49.999 no need to check war equal to". That allows for a round affcrrar af as muchas 0.1 cents which is way larger than one would ever expect, but not so large that it would overlap the next cent amount, 549 99. Cashiers salve this problem every day, without using division and dealing with remainders. So your program should be able to solve it too, without divide or modulus and without anath Think about it -- it's not hard "Never assume anything!" Test your program with various input values. Try to break your own program before you give someone else the opportunity to do so Submit your confile for grading and don't forget your identification code blocksStep 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