Answered step by step
Verified Expert Solution
Link Copied!

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 15 days of are $10 per day. After that, the charges are $6 per day.
For example, if a customer parks at the lot for 12 days, the total charge would be $120. If the customer parks at the lot for 21 days, it would cost $150(for the first 15 days)+ $36(for the remaining 6 days), for a total charge of $186. 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 s/he 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 parking_charges with four parameters: entermonth, enterday, exitmonth, and exitday. The customer enters the parking lot on the date entermonth/enterday, and exits the parking lot on the date exitmonth/exitday. Your function should print out, in a user-friendly 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 1 to 12, and enterday and exitday are appropriate day values for the corresponding month. Obviously, not all month/day values are valid. For example, dates such as 4/31 or 15/12 or 1/32 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 4/15 and exits on 4/16, s/he 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 28 days. A customer may park for any number of days (up to 365).
Read the documentation in the provided template for more details.
Ex: If the input is:
4
15
4
26
the output is:
Total number of days parked: 12
12 days at $10 per day: $120
0 days at $6 per day: $0
-------------------------
Total charges: $120
Ex: If the input is:
5
25
5
1
the output is:
Invalid!! Exit date occurs before enter date.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

Explain the difference between opportunities and ideas.

Answered: 1 week ago