samedi 18 février 2017

Create a program to calculate parking fare

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 and 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 a public lot. To encourage people to park for a short period of time, the management uses two different rates for each type of vehicle, as shown below:

Vehicle
First Rate:Car $0.00/hr first 3 hours Second Rate:$1.50/hr after 3 hours First Rate:Truck $1.00/hr first 2 hours Second Rate:$2.30/hr after 2 hours First Rate:Bus $2.00/hr first 1 hour Second Rate:$3.70/hr after 1 hour

You can assume that all vehicles will not be in the parking lot any later than midnight.

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 the data like shown below:

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 CHARGES Type of vehicle: TIME-IN XX : XX TIME-OUT XX : XX

PARKING TIME XX : XX ROUNDED TOTAL XX

TOTAL CHARGES $XX.XX

Aucun commentaire:

Enregistrer un commentaire