In this lab assignment you will practice:
static
variablesCreate a change machine program based on the Task 2: Money Changer program from Lab 1, with a few enhancements.
Important: do not use global variables for any part of this task!
If you do not have a working solution for Lab 1's Money Changer program, you can use this simplified version instead:
download change.cCreate another function to calculate the number of bills and coins to return as change. Remove the related code from main and use a call to this new function instead. The function will need at least two formal parameters: one for the amount of money to exchange (in cents), and a second for an array that will be used to store the resulting bill and coin amounts.
Modify your change calculation function so that it draws from a limited "inventory" of bills and coins that is reduced each time the function is used. If there are not enough of a larger denomination left in the inventory to cover the amount to exchange, compensate by using more of a lower denomination. If it is impossible to cover the full amount using what's left in the inventory, provide as much correct change as possible and report the unfulfilled amount using the return value of the function.
Given that there are two loonies, five quarters, and 22 pennies in the inventory when the function is called:
Completing all tasks in this lab should result in 1 or more .c files comprising a single program within a folder named like LastnameFirstname_lab4. Compress the folder into a ZIP archive and upload it to the D2L assignment.
The marks for this lab are heavily weighted towards good coding practice and style. Pay attention to your code formatting, use comments to clarify your code, and make sure you are using defines, arrays, loops, and functions effectively.
NOTE: This assignment is to be done individually. You can help one another with problems and questions, but in the end everyone must write and submit their own code.
Criteria | Marks |
---|---|
Programs compile and run without error | 3 |
Good coding style | 3 |
Task requirements met or exceeded | 3 |
Learning Outcomes achieved | 3 |
Total | 12 |