Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Pre-Processor Directive */
- #include <stdio.h>
- #include <stdbool.h>
- #define DISCOUNT_TIME_3 3
- #define DISCOUNT_TIME_10 10
- #define DISCOUNT_RATE_0.2 0.2
- #define DISCOUNT_RATE_0.4 0.4
- /* Function Prototypes */
- int inputParkingtime
- int validateParkingtime
- int
- char inputVehicaltype
- float validateVehicaltype
- float calcParkingfee
- float showParkingfee (
- /* Main Function */
- int main (void)
- {
- printf("Invalid Vehical Type\n");
- return (0)
- }
- /* User Defined Functions */
- /* Input Parking Time */
- int inputParkingtime
- {
- printf("Enter Parking Time: \n");
- scanf("%d", &inputParkingtime);
- return (0)
- }
- /* Validate Parking Time */
- int validateParkingtime (int inputParkingtime)
- {
- int parkingTime;
- if ( inputParkingtime <= 0 )
- printf("Wrong Parking Time \n");
- else if ( inputParkingtime > 24 )
- printf("Parking Time is Limited To 24 Hours\n);
- else if ( inputParkingtime > 3 ) && ( inputParkingtime < 10 )
- parkingTime = inputParkingtime * DISCOUNT_RATE_0.2
- else if ( inputParkingtime >= 10 ) && ( inputParkingtime < 25 )
- parkingTime = inputParkingtime * DISCOUNT_RATE_0.4
- else
- parkingTime = inputParkingtime
- return
- }
- /* Rejection of Vehical Type */
- char invalidVehicaltype
- {
- printf("Invalid Vehical Type");
- }
- /* Input vehical Type */
- char inputVehicaltype
- {
- printf("Enter Your Vehical Type (C, M or T): \n);
- scanf("%c", &inputVehicaltype);
- printf("Invalid Vehical Type");
- return
- }
- /* Validate Vehical Type */
- float validateVehicaltype (char inputVehicaltype)
- {
- if ( inputVehicaltype == C ) || ( inputVehicaltype == c )
- validateVehicaltype = 3.5
- else if ( inputVehicaltype == M ) || ( inputVehicaltype == m )
- validateVehicaltype = 1.5
- else if ( inputVehicaltype == T ) || ( inputVehicaltype == t )
- validateVehicaltype = 8.0
- else
- return ()
- }
- /* Calculate Parking Fee */
- float calcParkingfee (int parkingTime, float validateVehicaltype)
- {
- calcParkingfee = parkingTime * validateVehicaltype
- return ()
- }
- /* Show Parking Fee With 'float' Precision, to Two Decimal Places */
- float showParkingfee (char inputVehicaltype, int validateParkingtime, float calcParkingtime)
- {
- printf("%c, %d hrs Parking Fee: $%f\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment