The short-term, 0-24 hours, parking fee, F, at an international airport is given by the following formula: Fee = 5 if the car is parked between 0 and 3 hours inclusive Fee = 6 + int(h+1) if the car is parked more than 3 hours but less than or equal to 9 hours. Fee = 60 if the car is parked more than 9 hours but less than or equal to 24 hours where int(h + 1) is the integer value of h + 1. For example: int(3.2) is equal to 3. Write a program that prompts the user to enter the number of hours a car is parked at the airport and outputs the parking fee.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
The short-term, 0-24 hours, parking fee, F, at an international airport is given by the following formula:
Fee = 5 if the car is parked between 0 and 3 hours inclusive
Fee = 6 + int(h+1) if the car is parked more than 3 hours but less than or equal to 9 hours.
Fee = 60 if the car is parked more than 9 hours but less than or equal to 24 hours
where int(h + 1) is the integer value of h + 1.
For example: int(3.2) is equal to 3. Write a
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images