The cost of sending a package by an express delivery service is $15.00 for the f
ID: 670202 • Letter: T
Question
The cost of sending a package by an express delivery service is $15.00 for the first two pounds and $5 for each pound or fraction thereof over two pounds. If the package weighs more than 70 pounds, a $1500 excess weight surcharge is added to teh cost. No package over 100 pounds will be accepted. Using the if construct, write a MATLAB program that asks for the weight of a package in pounds and displays the resulting cost of mailing the package. Be sure to handle the case of overweight packages and those under 2 pounds.
Explanation / Answer
If x == 0
disp('the cost of sending package is $0.');
If x == 1
disp(''the cost of sending package is $15');
If x == 2
disp(''the cost of sending package is $15');
If x > 2 And x < 69.999
y = 15 + (x - 2) * 5;
fprintf('the cost of sending package is', y);
If x >= 70 And x <= 100
y = 15 + (x - 2) * 5 + 1500 ;
fprintf('the cost of sending package is', y);
%if the package size is bigger than 100 it should display exceed max weight.
If x > 100
fprintf('This item exceeds the max weight limit');
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.