makeChange - function few = makeChange(money) %Given an...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function few = makeChange(money) %Given an amount of money in decimal form (i.e. 1.50), write a function %makeChange that finds the fewest number of pieces of standard U.S. %currency required to reach the inputted amount of money. The function %should return this number as a double, and should only consider one %dollar bills, quarters, dimes, nickels, and pennies when calculating %the number of pieces of money required. %NOTICE: %Due to the way that MATLAB handles numbers, the following line of code %is required to make your code run correctly. Add this line of code %on the line immediately after your function header, before any other %code, where in is the input variable of your function: %in = round(in*100)/100; %Constraints: %You must use recursion for this problem. money = round(money*100)/100; %code given to fix Matlab if money==0 %terminating condition, because it is when there is no money left few = 0; %few will be 0 because no money is left elseif money>=1 %checks to account for all of the dollar bills first, because it is the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online