Many airports have separate parking lots for short-term and long-term parking. The cost to park depends on the lot you select, and how long you stay. Here is the rate structure for three types of parking lots at Portland International Airport (PDX):
13 views (last 30 days)
Show older comments
This is the code I have so far. I'm struggling including the maximum amount that can be charged in a day.
% Accept the inputs from the user
lot=input('Which parking lot are you using?\n1.Economy\n2.Long-term\n3.Short term\n');
fprintf('How many days and hours did you park for?\n');
days=input('Days : ');
hours=input('Hours : ');
cost=0;
% Calculate the total cost
if(lot==1)
cost=10*days+3*ceil(hours);
elseif(lot==2)
cost=21*days+3*ceil(hours);
elseif(lot==3)
cost=27*days+3*ceil(hours);
% For invalid inputs
else
fprintf('Enter valid inputs\n');
exit
end
% Display the total cost
fprintf('The total cost is %f\n',cost);
1 Comment
Sai Sri Pathuri
on 27 May 2020
The code works fine at my end. Can you attach the rate structure and elaborate the issue you are facing?
Answers (0)
See Also
Categories
Find more on Financial Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!