it\'s a MATLAB question I just need help coding it. 8.20 Most major airports hav
ID: 3599489 • Letter: I
Question
it's a MATLAB question I just need help coding it.
8.20 Most major airports have separate lots for long-term and short-term park ing. The cost to park depends on the lot you select, and how long you stay Consider this rate structure from the Salt Lake International Airport during the su mmer of 2016. Long-Term (Economy) Parking o The first hour is $2.00, and each additional hour or fraction thereof is $1.00 o Daily maximum $9.00 o Weekly maximum $60.00 Short-Term Parking o The first 30 minutes are $2.00 and each additional 20 minutes or fraction thereof is $1.00 o Daily maximum $32.00 Write a program that asks the u user the following: Which lot are you using? How many weeks, hours, days, and minutes did you park? Your program should then calculate the parking bilExplanation / Answer
Two outputs for longterm and shortterm are provided:
Kindly go through the code. Bill is calculated as said in the question:
If you have any doubts kindly you can comment.
*********************************************************************
Code:
choice=input("Choose 1 for short term and 2 for lomg term: ");
weeks=input("Enter number of weeks you parked: ");
days=input("Enter number of days you parked: ");
hours=input("Enter number of hours you parked: ");
minutes=input("Enter number of minutes you parked: ");
function bill=longterm(weeks,days,hours,minutes)
bill=0;
bill+=(weeks*60);
bill+=(days*9);
if(hours>0 && hours<=1)
bill+=2;
elseif(hours>0)
bill+=hours-1;
endif
hours=minutes/60;
if(hours>0 && hours<=1)
bill+=2;
elseif(hours>0)
bill+=hours-1;
endif
end
function bill=shortterm(weeks,days,hours,minutes)
bill=0;
bill+=(weeks*7*32);
bill+=(days*32);
if(minutes>0)
bill+=2;
minutes=minutes-30;
while(minutes>0)
bill+=minutes;
minutes-=20;
end
endif
minutes=hours*60;
if(minutes>0)
bill+=2;
minutes=minutes-30;
while(minutes>0)
bill+=minutes;
minutes-=20;
end
endif
end
if(choice==1)
bill=shortterm(weeks,days,hours,minutes)
elseif(choice==2)
bill=longterm(weeks,days,hours,minutes)
else
printf("Wrong choice ");
endif
*********************************************************************
Sample output 1:
Choose 1 for short term and 2 for lomg term:1
Enter number of weeks you parked:2
Enter number of days you parked:3
Enter number of hours you parked:4
Enter number of minutes you parked:5
bill = 1758
Sample output 2:
Choose 1 for short term and 2 for lomg term:2
Enter number of weeks you parked:2
Enter number of days you parked:3
Enter number of hours you parked:4
Enter number of minutes you parked:5
bill = 152
***********************************************************************
I hope this helps you.
If you find my answer helpful,
Kindly rate the answer.
All the best :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.