I am working on a program for class and I am having trouble understanding what the problem is asking. Can someone advise me on how I should write the code?
조회 수: 2 (최근 30일)
이전 댓글 표시
Most major airports have separate 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 2016.
Long term economy parking:
the first hour is $2 and each additional hour or fraction thereof is $1.
Daily max $9
weekly max $60
Short term parking:
the first 30 mins are $2 and each additional 20 min or fraction thereof is $1
Daily max $32
Create a program that asks the user the following: which lot are you using? how many weeks, hours, days, and minutes did you park? your program shoud then calculate the parking bill.
Daily maximum of $9 means $9 for each full day; weekly maximum of $60 means $60 for each full week, etc...
Assume the user enters positive integers for minutes/days/weeks/hours and that the user will enter appropriate number of days/weeks/hours. Program should account for user entering minutes greater than 60 and if the user enters an incorrect lot type.
Be sure to consider the situations when hours and/or minutes are entered as zero - test and account for these cases.
댓글 수: 0
채택된 답변
Walter Roberson
2025년 2월 21일
Create a program that asks the user the following: which lot are you using?
You can use input or questdlg or inputdlg or menu or create customized data entry such as using uilistbox
how many weeks, hours, days, and minutes did you park?
The rest is just calculations. How many full weeks were spent? Add that many times the weekly rate to the bill. Subtract off the full weeks from the input time. How many full days in what is left over? Add that many times the daily rate to the bill. Subtract off the full days in what was left over. Long term parking, determine the number of hours left over, rounded up; add that many times the hourly rate to the bill. Add an extra $1 for the first hour.
And similar logic for the short term lot.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!