Question: Write a C++ application using functions and selections to calculate and print charge for Flexi Parking. The Flexi Parking provides services for three city councils.

 Write a C++ application using functions and selections to calculate and

print charge for Flexi Parking. The Flexi Parking provides services for three

city councils. The rates vary depending on city councils and parking duration.

Write a C++ application using functions and selections to calculate and print charge for Flexi Parking. The Flexi Parking provides services for three city councils. The rates vary depending on city councils and parking duration. To accomplish the task, the following information is given: a. A code showing the city council: K for Kuala Lumpur, S for Subang Jaya, J for Kajang. b. An integer to show the hour a vehicle spent in the on-street parking slot. Each city council uses two different rates to compute the charge as shown in the following table: City Council Min. Charge for first 2 hours Rate (> 2 hours) K - Kuala Lumpur $ 3.00 $ 1.00 per each additional hour S-Subang Jaya $ 2.00 $ 0.60 per each additional hour J - Kajang $ 1.00 $ 0.50 per each additional hour Table 1: Parking Charge Table of the City Councils The program is to prompt the user for the inputs as shown below. (Bold numbers are typical responses.) City Council (K - Kuala Lumpur, S- Subang Jaya, J- Kajang ) Hour spent in the on-street parking slot : 7 : k The output format is shown below. CHARGE CITY COUNCIL HOUR SPENT Kuala Lumpur 7 hours : The hour spent in the parking slot is greater than 2 hours. The first 2 hours $ 3.00 The rest of 5 hours : $ 5.00 TOTAL CHARGE $ 8.00 Note that if the hour spent in the parking slot is less than or equal to 2 hours, a minimum charge is applied. Thus, for the above example, if the hour spent in the parking slot is 1 hour, the output should be CHARGE CITY COUNCIL HOUR SPENT Kuala Lumpur 1 hour The hour spent in the parking slot is less than or equal to 2 hours. TOTAL CHARGE $ 3.00 Define global constants for all minimum charge rates and the charge rates for additional hour. The program's design should use main (10 marks) and at least the FOUR(4) functions described below: a. Function 1(read_input): Read input data from the keyboard. This function will be called by main program. It uses addresses/references to read all input data and place them in the calling function's variables. Assume the user enters correct input. (20 marks) b. Function 2 (print_charge): Print the charge with input data. This function will be called by main program. (30 marks) c. Calculate values. This section consists of two sub-functions. Both functions will be called by the Function 2 defined for part b. Function 3(find_charges): Find minimum parking charge and charge rate for additional hour with city council code. It uses addresses/references to place charge rates in the calling function's variables. This function also prints city council name. (15 marks) Function 4(compute_total): Calculate and return the total charge with hours, minimum parking charge and charge rate for additional hour. (15 marks) main hour council_code, council_code, hour read_input print_charge hour, council_code Po main-charge min_charge. 1 total_charge add_rate compute_total find_charges Structure Chart with Data Flow

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!