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

Homework Assignment (due 10/13/2017) Most major airports have separate lots for

ID: 3590486 • Letter: H

Question

Homework Assignment (due 10/13/2017) Most major airports have separate lots for long-term and short-term parking. The cost to park depends on the lot you select, and how long you stay. Consider this rate schedule from Salt Lake International Airport Long-Term (Economy) Parking: o The first hour is $1.00, and each additional hour or fraction thereof is $1.00 o Daily maximum $6.00 Weekly maximum $42.00 o Write a Matlab script that calculates the cost of long-term parking if it is given the number of weeks, days, hours, and minutes you parked.

Explanation / Answer

function bill=getLongTermParkingBill(week,day,hour,minute)
% lets first compute for week and day as that is easy
bill = 42*week + 6*day;
  
% lets compute hours in given minute and then days in given hour and minutes
calcHour = ceil(minute/60) + hour;
calcDay = 0;
if calcHour > 24
calcDay = floor(calcHour/24);
calcHour = calcHour - calcDay*24;
end
  
if calcHour > 6
calcHour = 6;
end
  
bill = bill + 6*calcDay + calcHour;
end