I want to write a program that determines the bill for car parking. I asked my friend to put together a description of what I want to do. Can someone look at this and give me a good code to do this?

This program requires you to input information about vehicles in a parking lot and calculate their bill for parking. The input for a vehicle will consist of a character and four integer values.

The character will be either C, c, T, t, B or b : this indicates car, truck, or bus.

The first integer ( 0 <= hr_in < 24) will represent the hour of the arrival time of the vehicle

The second integer ( 0 <= min_in < 60) will represent the minutes of the arrival time of the vehicle

The third integer ( 0 <= hr_out < 24) will represent the hour of the departure time of the vehicle

The fourth integer ( 0 <= min_out < 60) will represent the minutes of the departure time of the vehicle

For example C 10 30 13 0 would mean that a car arrived at 10:30 and left at 13:00.


Parking fees are detailed in the table that follows:

Type of vehicle Initial rate Rate for additional time

Car First 3 hours are free
$1.50 per hour after the first 3
Truck First 2 hours cost $2.50
$5.00 per hour after the first 2
Bus First hour costs $5.00 $7.50 per hour after the first


Notes:
1. Customers pay in full for fractional parts of an hour.
2. Make sure that your input prompts are lucid!
3. The output should include a labeled echo print of the input values, the actual time in the parking lot ( hours and minutes), the number of hours the customer will be charged for, and the total charges.
4. Print an error message for illegal vehicle types.
5. No car is allowed to stay in the lot for more than 24 hours. You do not need to check for this. Also, you may assume that the departure time is greater than the arrival time.
6. After you have your code working correctly for one vehicle, add a while loop to allow the user to input any number of vehicles. Print a message at the conclusion of the loop, indicating that processing is complete.


Type of vehicle Arrival time Departure time
C (or c) 6 30
9 25
C (or c)
10 6 10 59
T ( or t) 5 33 7 59

B ( or b)
14 24 15 20

C (or c) 14 45 17 47

C (or c) 8 15 22 0
T ( or t)
14 44 20 55
T ( or t)
14 45 16 30


Sample output for one vehicle. ( User input in blue )

Type of vehicle: C for car, T for truck, B for bus>>> B

hours in 7
min in 5
hours out 10
min out 15

time in 7:05
time out 10:15

time in garage 3:10

you will pay for 4 hours.

Bill for your bus is $27.50
=================================

You want us to do your homework? Not gonna happen dude! Make an effort to deal with it yourself first, and we will be happy to make suggestions and corrections.

It's not homework. It's something I'm doing for my friend. He wrote out a description of what he wants. I'm just not trying to write it out haha.

I'm not going to write it for you but what you need is an array of types (C, T, B), an input reader, and be able to split the input into it's components with error checks.

Once you split the input you run the tests on it, these include "IF (car) THEN figure out hours" and so on.

The hours is an easy math calculation.

Output the result.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.