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

Matlab Currency conversion A currency exchange booth exchanges 1 US dollar to 11

ID: 3866761 • Letter: M

Question

Matlab

Currency conversion A currency exchange booth exchanges 1 US dollar to 119.771 Japanese yen. The currency exchange booth rounds down to the nearest yen. Assign totalYen with the amount of yen distributed to a customer given totalDollars. Ex: If totalDollars is 10 dollars, then totalYen is 1197 Your Function Save CReset EE MATLAB Documentation I function totalYen = ConvertToYen (totalDollars) 2% tota!Dollars : Amount to convert in dollars % Assign totalYen with the amount of yen distributed given tota!Dollars % Exchange rate is 119.771 Japanese yen for 1 US dollar totalYen = 0; 4 6 7 8 end

Explanation / Answer

function totalYen = ConvertToYen(totalDollars)
%totalDollars : Amount to convert on dollars

% Assign totalYen with the amount of Yen distributed given totalDollars

%Exchange rate is 119.771 Japanese yen for 1 US dollars

totalYen = floor(totalDollars * 119.771);

end

fprintf('Yen for 10 dollars = %d ', ConvertToYen(10))
fprintf('Yen for 325 dollars = %i ', ConvertToYen(325))

Output:

Yen for 10 dollars = 1197   

Yen for 325 dollars = 38925