I need help to write a program in MATLAB that asks the user the following: • Whi
ID: 3684585 • Letter: I
Question
I need help to write a program in MATLAB that asks the user the following:
• Which lot are you using?
• How many weeks, hours, days, and minutes did you park?
The program should then calculate the parking bill.
The information for this problem is below.
Consider the parking rates from an airport
o Long-Term (Economy) Parking at Lot 1
1. The first hour is $1.00, and each additional hour or fraction thereof is $1.00
2. Daily maximum $6.00
3. Weekly maximum $40.00
o Short-Term Parking at Lot 2
1. The first 30 minutes are free and each additional 20 minutes or fraction
thereof is $1.00
2. Daily maximum $25.00
Explanation / Answer
lot = input("Which parking lot were you using? Type 1 or 2");
time1 = input("How many weeks, hours, days, and minutes did you park? Type as [2 3 4 5]");
answ=0;
temp=0;
if lot == 1
answ=answ+time1(1)*40;
temp=time1(2)*6;
if temp>40
temp=40;
end
answ = answ + temp;
temp=time1(3)*1;
if time1(4)>0
temp = temp+1
end
if temp>6
temp=6;
end
answ = answ + temp;
end
if lot == 2
answ = answ+(time1(1)*7+time1(2))*25;
temp = time1(3)*60+time1(4)-30;
if temp<0
temp=0;
else
temp = ceil(temp/20);
end
if(temp>25)
temp=25;
end
answ = answ+temp;
end
disp(answ);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.