20.7k views
4 votes
The short-term, 0-24 hours, parking fee, F, at an international airport is given by the following formula:  5, if 0 # h # 3 F563int(h11), if3,h#9  6 0 , i f 9 , h # 2 4 where int(h + 1) is the integer value of h + 1. For example, int(3.2) = 3, int(4.8) = 4. Write a program that prompts the user to enter the num- ber of hours a car is parked at the airport and outputs the parking fee.

User Eksortso
by
3.7k points

1 Answer

4 votes

Final answer:

To write a program that calculates the parking fee at an international airport, you can use an if-else statement to check the number of hours the car is parked and calculate the fee accordingly.

Step-by-step explanation:

To write a program that calculates the parking fee, you can use an if-else statement to check the number of hours the car is parked and calculate the fee accordingly. Here's a step-by-step explanation:

  1. Prompt the user to enter the number of hours the car is parked.
  2. Read the input and store it in a variable, let's say 'hours'.
  3. Use an if-else statement to check the value of 'hours' and calculate the fee based on the given formula.
  4. If 'hours' is between 0 and 3, set the fee 'F' to 5.
  5. If 'hours' is between 3 and 9, calculate 'int(h+1)' and set 'F' to 63 times 'int(h+1)' minus 11.
  6. If 'hours' is between 9 and 24, set 'F' to 60.
  7. Output the value of 'F' as the parking fee.

User CzarMatt
by
4.7k points