Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please, I cannot do the coding for this one. There's always an error with makeChangeRecursive function in defining. An expert has already answered. But it's
Please, I cannot do the coding for this one. There's always an error with makeChangeRecursive function in defining. An expert has already answered. But it's not right. So, I'm reposting it. Thank you for your help.
Problem 2: Linear Recursion Write a function [change, flagmakeChangeRecursive (cost,paid) that takes the cost of an item cost (a lxl double) and the amount paid by the buyer paid (a lxl double), and returns a n x 1 column array of doubles change containing the bills that the seller should give back to the buyer in decreasing order and flag a lxl logical true or false saying whether the transaction was "completed". Ifpaid is less than cost, flagis false and you should display a warning in the command window saying "That's not enough to buy that item." and change is assigned as an empty array. If cost and paid are equal the change is assigned as an empty array and flag is true. Ifpaid is greater than cost, flag is true and change is the difference between the two made by combining the denominations: 100, 50, 20, 10, 5, 2, and 1 IMPORTANT! The function makeChangeRecursiveMUST use recursion to create the variable change. No points will be awarded if you use a for or while loops. TEST CASE 1 [change, flag)-makeChangeecursive (2,100) change - 50 20 20 flag TEST CASE 2 [change, flag-makeChangeRecursive (3,20) change = 10 flag = TEST CASE 3 >>[change, flag]makeChangeRecursive (20,20) change- flag >> [change, flagmakeChangeRecursive (59,20) Warning: That's not enough to buy that item ENGR 215 Lab Assignment #4 Due See Canvas Due Date > In makeChangeRecursive at 22 change- [i flag >> [change, flagmakeChangeRecursive (50,100) change - 50 flagStep 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