Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program Specifications In this problem, you are asked to write a program to calculate and print the total parking charges for a customer at a
Program Specifications In this problem, you are asked to write a program to calculate and print the total parking charges for a customer at a long term parking lot. The charges are calculated according to the number of days parked at the lot. The parking charges for the first days of are $ per day. After that, the charges are $ per day.
For example, if a customer parks at the lot for days, the total charge would be $ If the customer parks at the lot for days, it would cost $for the first days $for the remaining days for a total charge of $ You are asked to complete the function, whose parameters are the date on which the customer enters the parking lot and the date on which she exits the lot. The function then prints out the total parking charges for the customer. Further details are provided below.
First take four integer representing entermonth, enterday, exitmonth, and exitday. Complete the function called maxdays with one parameter month and parkingcharges with four parameters: entermonth, enterday, exitmonth, and exitday. The customer enters the parking lot on the date entermonthenterday and exits the parking lot on the date exitmonthexitday Your function should print out, in a userfriendly way, the total parking charges for the customer. Some points to note:
Each of the four parameters to the function is a positive integer, where entermonth and exitmonth are integers in the range to and enterday and exitday are appropriate day values for the corresponding month. Obviously, not all monthday values are valid. For example, dates such as or or are all invalid. However, you are not required to check for the validity of the enter and exit dates. That is you may assume that the dates are valid.
The exit date must come after the enter date. You are required to check for this condition. If the exit date does not occur after the enter date, your function should print an appropriate error message and return see sample run below Assume that the customer enters and exits the parking lot in the same calendar year, so the exit month is always greater than or equal to the enter month.
If the exit date comes after the enter date, your function should then proceed to calculate the parking charges. When calculating the total number of days parked, the days on which the customer enters and exits are included in the total count. For example, if the customer enters on and exits on she parks for a total of two days. When calculating the total number of days parked, make sure that you count the number of days in each month correctly. You may assume that February always has days. A customer may park for any number of days up to
Read the documentation in the provided template for more details.
Ex: If the input is:
the output is:
Total number of days parked:
days at $ per day: $
days at $ per day: $
Total charges: $
Ex: If the input is:
the output is:
Invalid!! Exit date occurs before enter date.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started