215k views
3 votes
A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part of an hour thereof in excess of three hours. The maximum charge for any given 24 -hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calclulates and prints the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter (cin) the hours parked for each customer. Your program should print the results in a neat tabular format (as shown below) and should calculate and print the TOTAL of all receipts. The program should use the function calculateCharges to calculate and return the charge for each customer to the main function. The main function then prints these charges. Your outputs should appear in the following format: (5 marks)

User Vanuan
by
7.0k points

1 Answer

4 votes

Final answer:

A programming solution is sought for calculating parking charges based on specific pricing rules, utilizing a function to compute individual charges and the main function to display and sum these charges.

Step-by-step explanation:

The student's question is essentially asking for a programming solution that calculates parking charges based on a set of rules provided by a parking garage. The charges depend on the duration that a car is parked and are capped at a maximum for a 24-hour period. To compute the parking charges for three customers, a calculateCharges function is needed within the program.

This function receives the number of hours a customer parked as input and returns the parking charge based on the garage's pricing structure. The main function will call calculateCharges for each customer, collect the returned values, display them in a tabular format, and calculate the total receipts.

User Alassane Ndiaye
by
7.8k points