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

Please show all steps and comments. Thank you! The parking hours to be used by t

ID: 3879757 • Letter: P

Question

Please show all steps and comments. Thank you!

The parking hours to be used by three people at Vancouver Airport over 10 days are given below. 4.0 1.5 6.0 0.75 12.0 72.0 0.0 0.04.0 2.75 48.0 0.05.5 1.00 3.00 2.00 1.5 2.5 4.0 1.5 1.0 1.5 5.0 8.01.5 2.0 1.5 1.75 12.0 2.0 The rate structure for parking is: Short-term parking: First 30 minutes S2.50 and each additional 15 minutes or fraction thereof is S 1.00. Daily maximum is S 25.00. Long-term parking: First 3 hours S 10.00 and each additional hour or fraction thereof is $3.00. Daily maximum is $ 18.00. Weekly maximum is $ 80.00. Write a MATLAB code to decide which parking lot (short-term or long-term) should be used each time to minimize the cost and calculate the total minimum parking bill over the 10 days for each person. (30 marks)

Explanation / Answer

clc

%calculating cost of short-term parking first

person1=[4.0,1.5,6.0,0.75,12.0,72,0.0,0.0,4.0,2.75] %to store the data related to person 1,similarly for other 2

person2=[48.0,0.0,5.5,1.0,3.0,2.0,1.5,2.5,4.0,1.5]

person3=[1.0,1.5,5.0,8.0,1.5,2.0,1.5,1.75,12.0,2.0]

shortp1=[0,0,0,0,0,0,0,0,0,0]

shortp2=[0,0,0,0,0,0,0,0,0,0] %to save the cost of short term parking for each person

shortp3=[0,0,0,0,0,0,0,0,0,0]

for n=1:10

if(person1(n)>24)

x=person1(n)/24

shortp1(n)=x*25

else

shortp1(n)=2.5

if(person1(n)>.5) %if duration greater than 30 min i.e, 0.5 hours

person1(n)=person1(n)-0.5 %to claculate cost for the additional time after initial 30 min

while(person1(n)>0) %if time still remaining

shortp1(n)=shortp1(n)+1 %plus 1 $ for each 15 min

if(shortp1(n)>25)

shortp1(n)=25 %if 25$ crossed then make it 25$ as maximum is 25$

break

end

person1(n)=person1(n)-0.25 %decrementing 15 min

end

end

end

end

%similarlr repeat for person2,person3

%calculating for long term parking

longp1=[0,0,0,0,0,0,0,0,0,0]

longp2=[0,0,0,0,0,0,0,0,0,0]

longp3=[0,0,0,0,0,0,0,0,0,0]

person1=[4.0,1.5,6.0,0.75,12.0,72,0.0,0.0,4.0,2.75]

person2=[48.0,0.0,5.5,1.0,3.0,2.0,1.5,2.5,4.0,1.5]

person3=[1.0,1.5,5.0,8.0,1.5,2.0,1.5,1.75,12.0,2.0]

for n=1:10

if(person1(n)>24)

x=person1(n)/24

longp1(n)=x*18

else

longp1(n)=10

if(person1(n)>3) %if duration greater than 3 hours

person1(n)=person1(n)-3 %to claculate cost for the additional time after initial 3 hours

while(person1(n)>0) %if time still remaining

longp1(n)=longp1(n)+1 %plus 1 $ for each 15 min

if(longp1(n)>18)

longp1(n)=18 %if 18$ crossed then make it 18$ as maximum is 18$ is max for a day

break

end

person1(n)=person1(n)-1 %decrementing 1 hour

end

end

end

end

%similarlr repeat for person2,person3
%to calculate minimum cost for each person
result=0
for n=1:10
if(shortp1(n)<=longp1(n))
result=result+shortp1(n)
else
result=result+longp1(n)
end
end
%similarly repeat for other two persons

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