### Kindly need a help ...

I am just a new student for programming .. i really hope i can find help here coz i badly needed it now ..

I have here a program .. I hope you ca help me bout this ..
much appreciated your help thank you..

Write a C program to calculate the parking fare for customers who park their cars in a parking lot when the following information is given:

a.) A character showing the type of vehicle: C for car, B for bus, T for truck.
b.) An integer between 0 and 24 showing the hour the vehicle entered the lot.
c.) An integer between 0 and 60 showing the minute the vehicle entered the lot.
d.) An integer between 0 and 24 showing the hour the vehicle left the lot.
e.) An integer between 0 and 60 showing the minute the vehicle left the lot.

This is s public lot. To encourage people to park for a short period of time, the management uses two different rates for each type of vehicle, shown in the Table 5-11.

---------------------------------------------------------------------------------------------------------------------
Vehicle | First Rate | Second Rate |
---------------------------------------------------------------------------------------------------------------------

CAR | \$0.00/hr first 3 hr | \$1.50/hr after 3 hr |
TRUCK | \$1.00/hr first 2 hr | \$2.30/hr after 2 hr |
BUS | \$2.00/hr for first hr | \$3.70/hr after first hr |

TABLE 5-11 Rates for Project

No vehicle is allowed to stay in the parking lot later than midnight; it will be towed away.
The input data consist of a character and a set of four integers representing the type of vehicle and the entering and leaving hours and minutes. But these pieces of data must be input into the computer in a user-friendly way. In other words, the computer must prompt the user to enter each piece of data as shown below. ( Color indicates typical data.)

Type of vehicle ? C
Hour vehicle entered lot ( 0 - 24 ) ? 14
Minute vehicle entered lot ( 0 - 60 ) ? 23
Hour vehicle left lot ( 0 - 24 ) ? 18
Minute vehicle left lot ( 0 - 60 ) ? 8

The output format is shown below.

PARKING LOT CHARGE

Type of vehicle : Car or Bus or Truck
TIME-IN XX : XX
TIME-OUT XX: XX
------------
PARKING TIME XX : XX
ROUNDED TOTAL XX
------------

TOTAL CHARGE \$XX.XX

This program must first calculate the actual time spent in the parking lot for each vehicle. This means using modulo arithmetic to handle time calculation. We can calculate this in many ways, one of which is shown below. To calculate the time spent in the parking lot, use the following algorithm:

a.) Compare the minute portion of the leaving and the entering time.
If the first one is smaller than the second,

- add 60 to the minute portion of the leaving time.
- Subtract 1 from the hour portion of the leaving time.

b.) Subtract the hour portions.
c.) Subtract the minute portions.
d.) Since there are no fractional hour charges, the program must also round the parking time up to the next hour before calculating the charge. The program should use the switch statement to distinguish between the different types of vehicles.

A well structured program design is required. A typical solution will use several functions besides main. Before you start programming , prepare a structure chart. Run your program six times with the data shown in Table 5-12.

------------------------------------------------------------------------------------------------------------------------------------------------
Test | Type | Hour In | Minute in | Hour Out | Minute Out |

1 | C | 12 | 40 | 14 | 22 |
2 | B | 8 | 20 | 8 | 40 |
3 | T | 2 | 0 | 3 | 59 |
4 | C | 12 | 40 | 16 | 22 |
5 | B | 8 | 20 | 14 | 20 |
6 | T | 2 | 0 | 12 | 0 |
------------------------------------------------------------------------------------------------------------------------------------------------
You are not even going to give him an answer?

Try something like:

 ``1234567`` ``````struct Info{ int StartMinutes; int StartHours; int EndHours; int EndMinutes; char Type; };``````

Then In your main code you reference it like:
 ``123`` ``````Info Vehicle1; std::cin >> Vehicle1.StartMinutes; std::cin >> Vehicle1.StartHours;``````

Then Also Get the Time the vehicle left...

Subtract the start from the finish to get the time they were there.
Then Apply The rate and get the Charge for being there.

For printing try something similar to
 ``12`` ``````for(The amount of Cars) std::cout << CurrentLoopCount << "|" << Vehicle1.Type << "|"... And So on``````
Last edited on
Topic archived. No new replies allowed.