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)
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);

Answers (0)

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!