How to create a for/ while loop until a condition is met
Show older comments
I'm creating a function to determine the cost of parking at an airport. I have specific time requirements for the time parked and the related cost. My question is how can I change my time=input line to incorporate weeks, hours, days, and mins. Also for each lot there is a daily maximum which once you reach you can't be charge any more that day. How do I change my code to account for multiple days in the same lot? Please let me know if you have any questions about what I am asking.
Short Term Parking Lot
Duration Cost
| 0-30 min | Free (day 1 only)
| 31-60 min | $2.00
| Each additional hour | $1.00
| Daily maximum | $14.00
function parking_meter
%This function gives you the total cost of parking for airfair for 4 types of parking lots at Northwest Arkansas Regional
%To determine the cost of the parking the user will then select a parking
%lot
cost=menu('Select a parking lot to calculate your parking cost, a', 'Short Term','Intermediate', 'Long Term', 'Economy')
switch cost
case 1
time=input('input the duration you parked in minutes \n')
if 0<=time && time<=30
disp('Free for one day')
elseif 31<=time && time<=60
disp('$2.00')
elseif time > 60
a_cost=time./60*1;
cost= 2+a_cost;
disp(cost)
end
%How do you incorporate the daily maximum of $14 11 additonal hours
...........
end
1 Comment
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!