Write a program that works out the amount a person has to pay for parking in a car park in a tourist town. If they say they are disabled, they are told it is free. Otherwise they enter the number of hours as a whole number (1-8) that they wish to park as well as whether they have an “I live locally” badge or are an old age pensioner both of which leads to a discount. The program tells them the cost to park. The calculation is done in this program as follows. If they are disabled it is free. Otherwise ... Take number of hours they wish to park and give a basic charge:
-
Parking Charges Program in java
-
Write a program that works out the amount a person has to pay for parking in a car park in a tourist town. If they say they are disabled, they are told it is free. Otherwise they enter the number of hours as a whole number (1-8) that they wish to park as well as whether they have an “I live locally” badge or are an old age pensioner both of which leads to a discount. The program tells them the cost to park.
The calculation is done in this program as follows. If they are disabled it is free. Otherwise ... Take number of hours they wish to park and give a basic charge:
• • • •
1 hour: 3.00 pounds 2-4 hours: 4.00 pounds 5-6 hours: 4.50 pounds 7-8 hours: 5.50 pounds
Next modify the resulting charge based on whether they are local or not:
•
If local: subtract 1 pound
If OAP: subtract 2 pounds
Your program MUST include methods including ones that
-
- asks for the hours and returns the basic charge.
-
- asks whether they live locally / are an OAP and returns the amount to subtract
An example run of the program (words in bold are typed by the user: pop-up boxes may be used for I/O): Are you disabled? Yes
Parking for you is freeAnother example run:
Are you disabled? No
How many hours do you wish to park (1-8)? 5 Do you have an ”I live locally badge”? Yes Are you an OAP? Yes
The parking charge for you is 1.50 pounds.Another example run:
Are you disabled? No
How many hours do you wish to park (1-8)? 5 Do you have an ”I live locally badge”? Yes Are you an OAP? Yes
The parking charge for you is 1.50 pounds.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images