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

Most major airports have separate parking lots for long-term and short-term park

ID: 3622198 • Letter: M

Question

Most major airports have separate parking 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 structure from the Salt Lake International Airport during the summer of 2008.

+ Long-Term (Economy) Parking
--+ The first hour is $1.00, and each additional hour or fraction thereof is $1.00.
--+ Daily maximum $6.00
--+ Weekly maximum $42.00
+ Short-Term Parking
--+ The first 30 minutes of parking are free and each additional 20 minutes or fraction thereof is $1.00
--+ Daily maximum $25.00
Write a program that asks the user the following:
--+ Which lot are you using?
--+ How many weeks, days, hours, and minutes did you park?

Your program should then calculate the parking bill.

You must also include an error check using a conditional loop to ensure correct input for the lot type, i.e. 1 or 2. Use switch/case to determine the cost for the type lot entered. Print the input as well as the cost with appropriate labeling. Use fprintf for all output with appropriate labeling.



I started the programing something like this but i am haveing truble i keep geting erross

lot=menu('Which lot do you want to park at?','Long-Term Lot','Short-term Lot');
disp('How long did you park in the lot?');
Weeks=input('Weeks:');
Days=input('Days:');
Hours=input('Hours:');
Minutes=input('Minutes:');
switch lot
case 1
bill=LongTermBill(Weeks,Days,Hours,Minutes);
case 2
bill=ShorTermBill(Weeks,Days,Hours,Minutes);
fprintf('Ticket Number Time Stayed:%3d Weeks %2d Days %2d Hours %2d Minutes Fee: %4d Dollars ',Weeks,Days,Hours,Minutes,bill);
end
function result=LongTermBill(w,d,h,m)
% Makes the calculation the Long-Term Bill
hours=h+(m/60); %adds hours and minutes
hours=ceil(hours);%rounds to the nearest hour
if(hours>=6)
LTbill=(42*w)+(6*d)+6; %adds the total bill
else
LTbill=(42*w)+(6*d)+hours; %adds the total bill
result=Thebill
end
function result=ShortTermBill(w,d,h,m)
% Makes the calculation the Short-Term Bill
minutes=((h*60)+m)-30);
MinutesPrice=minutes/20;
MinutesPrice=ceil(MinutesPrice);
WeekPrice=7*25; %price to stay in st parking for a week
if(MinutesPrice>=25)
STbill=(WeekPrice*w)+(25*d)+25; % adds the total bill
else
STbill=(WeekPrice*w)+(25*d)+MinutesPrice; %adds the total bill
result=STbill;
end

]

Explanation / Answer

In both your functions the line result=STbill and result = LTbill should be outside the if else block, it should be the last line in the function. Also in ShortTermBill remove the last closing paranthesis when calculating minutes(first line). This should take care of the errors. However, based on the question, you should have an error check based on the weeks, days, hrs, min input by the usr whether it is valid for the option selected by the user(Long term or Short term).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote