Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This activity uses a 3rd party app. Though your activity may be recorded, a refr

ID: 3862066 • Letter: T

Question

This activity uses a 3rd party app. Though your activity may be recorded, a refresh may be required to update the banner to the left A cashier distributes change using the maximum number of five dollar bills. followed by one dollar bills Given amount To Change. assign numFives and numOnes with the number of five dollar and one dollar bills distributed Use/and mod and a rounding function. numFives and numOnes should be integer values. If amountToChange is 19. then numFives is 3 and numOnes is 4 function [numFives. numOnes] = Compute Change (amount To Change) % amount ToChange: Amount of change in dollars % Assign numFives with the number of five dollar bills distributed numFives = Phi; % Assign nunOnes with number of one dollar bills distributed numOnes = Phi; end Code to call your function when you click Run Computer Change (19) C Reset

Explanation / Answer

%matlab code

function [numFives,numOnes] = ComputeChange(amountToChange)
% fives
numFives = amountToChange/5;
numFives = round(numFives);
  
if numFives*5 > amountToChange
amountToChange = amountToChange - (numFives-1)*5;
numFives = numFives -1
else
amountToChange = amountToChange - numFives*5;
numFives = numFives
end
  
% get ones
numOnes = amountToChange
end


ComputeChange(19);
%output:
% numFives = 3   
% numOnes = 4