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

This is Mathlab Computer engineering Write a MATLAB function that calculates the

ID: 2081990 • Letter: T

Question

This is Mathlab Computer engineering Write a MATLAB function that calculates the cost of shipment of a package. If the weight of the package is 5lbs of less, cost is $15. The cost increases by $2/lb for weight above 5lbs and less than 70lbs. If the package is 70lbs or higher, the additional cost per pound is still $2/lb but there is an additional surcharge of $15. Any packages weighing above 100 lbs should not be accepted. The function should accept weight of the package as input and return the cost of shipment.

Explanation / Answer

MATLAB :-

clc
clear
% Enter weight of package
Wp = input('Enter Weight of package in lbs = ')
if (Wp<=5)
Wp
disp('Cost of Package is $ = ')
C = 15
else if (Wp>5 && Wp <70)
Wp
disp('Cost of Package is $ = ')
C = 15 + (Wp-5)*2
else if (Wp>=70 && Wp<=100)
Wp
disp('Cost of Package is $ = ')
C = (Wp-5)*2+15 + 15
else if (Wp>100)
disp('This Package Not accepted')
end
end
end
end

OUTPUT :-

Enter Weight of package in lbs = 3

Wp =

3


Wp =

3

Cost of Package is $ =

C =

15

ii)

Enter Weight of package in lbs = 20

Wp =

20


Wp =

20

Cost of Package is $ =

C =

45

iii)

Enter Weight of package in lbs = 80

Wp =

80


Wp =

80

Cost of Package is $ =

C =

180

iv)

Enter Weight of package in lbs = 120

Wp =

120

This Package Not accepted
>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote