Fix the code % FIX ME To Make It run correctly. Use the Programming Language ---
ID: 3857794 • Letter: F
Question
Fix the code % FIX ME
To Make It run correctly.
Use the Programming Language ---- > MATLAB <---
Assessments Tests
Check if CalculateDelivery(65.4) returns 36
Check if CalculateDelivery(50.3) returns 21
Luggage delivery Assign deliveryCost with the cost (in dollars) to deliver a piece of baggage weighing baggageWeight. The baggage delivery service charges twenty dollars for the first 50 pounds and one dolllar for each additional pound. The baggage delivery service calculates delivery charge by rounding to the next pound. Assume baggageWeight is always greater than 50 pounds Ex: If baggageWeight is 65.4 pounds, then the weight is rounded to 66 pounds and deliveryCost is 20(16 1) 36 dollars. Your Function Save CReset MATLAB Documentation function deliveryCost- CalculateDelivery (baggageweight) 2% baggageweight: Weight of baggage in pounds 4 5 6 7 end % Assign delive ryCost with the delivery a piece of baggage weighing baggageweight deliveryCost Code to call your function C Reset 1 CalculateDelivery (65.4)Explanation / Answer
Funtion ----->CalculateDelivery.m
function [ deliveryCost ] = CalculateDelivery( baggageWeight )
%baggageWeight : Weight of baggage in pounds
% Assign deliveryCost with the delivery a piece of baggage weighing
% baggageWeight
deliveryCost = 0;
if baggageWeight <= 50
deliveryCost = 20;
else
baggageWeight = ceil(baggageWeight);
deliveryCost = 20+(baggageWeight-50)
end
end
Code to call function -------->
>> CalculateDelivery(65.4)
deliveryCost = 36
>> CalculateDelivery(50.3)
deliveryCost = 21
Function -------->ConvertToYen.m
function [ totalYen ] = ConvertToYen( totalDollars )
%totalDollars : amount to convert into dollars
% Assign totalYen with the amount of Yen distributed given totalDollars
% Exachane rate is 119.771 Japanese Yen for 1 US dollar
totalYen = 0;
totalYen = floor(totalDollars * 119.771);
end
Code to call function -------->
>> ConvertToYen(10)
ans = 1197
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.