deadlyhunter88

My code for parking

Apr 30th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. /* Pre-Processor Directive */
  2.  
  3. #include <stdio.h>
  4. #include <stdbool.h>
  5.  
  6. #define DISCOUNT_TIME_3 3
  7. #define DISCOUNT_TIME_10 10
  8. #define DISCOUNT_RATE_0.2 0.2
  9. #define DISCOUNT_RATE_0.4 0.4
  10.  
  11. /* Function Prototypes */
  12.  
  13. int inputParkingtime
  14. int validateParkingtime
  15. int
  16. char inputVehicaltype
  17. float validateVehicaltype
  18. float calcParkingfee
  19. float showParkingfee (
  20.  
  21. /* Main Function */
  22.  
  23. int main (void)
  24. {
  25.  
  26. printf("Invalid Vehical Type\n");
  27.  
  28.  
  29. return (0)
  30.  
  31. }
  32.  
  33. /* User Defined Functions */
  34.  
  35. /* Input Parking Time */
  36.  
  37. int inputParkingtime
  38. {
  39. printf("Enter Parking Time: \n");
  40. scanf("%d", &inputParkingtime);
  41.  
  42. return (0)
  43. }
  44.  
  45. /* Validate Parking Time */
  46. int validateParkingtime (int inputParkingtime)
  47. {
  48. int parkingTime;
  49.  
  50. if ( inputParkingtime <= 0 )
  51. printf("Wrong Parking Time \n");
  52. else if ( inputParkingtime > 24 )
  53. printf("Parking Time is Limited To 24 Hours\n);
  54. else if ( inputParkingtime > 3 ) && ( inputParkingtime < 10 )
  55. parkingTime = inputParkingtime * DISCOUNT_RATE_0.2
  56. else if ( inputParkingtime >= 10 ) && ( inputParkingtime < 25 )
  57. parkingTime = inputParkingtime * DISCOUNT_RATE_0.4
  58. else
  59. parkingTime = inputParkingtime
  60.  
  61. return
  62. }
  63.  
  64.  
  65. /* Rejection of Vehical Type */
  66. char invalidVehicaltype
  67. {
  68.  
  69. printf("Invalid Vehical Type");
  70.  
  71. }
  72. /* Input vehical Type */
  73. char inputVehicaltype
  74. {
  75. printf("Enter Your Vehical Type (C, M or T): \n);
  76. scanf("%c", &inputVehicaltype);
  77.  
  78. printf("Invalid Vehical Type");
  79. return
  80. }
  81.  
  82. /* Validate Vehical Type */
  83. float validateVehicaltype (char inputVehicaltype)
  84. {
  85. if ( inputVehicaltype == C ) || ( inputVehicaltype == c )
  86. validateVehicaltype = 3.5
  87. else if ( inputVehicaltype == M ) || ( inputVehicaltype == m )
  88. validateVehicaltype = 1.5
  89. else if ( inputVehicaltype == T ) || ( inputVehicaltype == t )
  90. validateVehicaltype = 8.0
  91. else
  92.  
  93. return ()
  94. }
  95.  
  96. /* Calculate Parking Fee */
  97. float calcParkingfee (int parkingTime, float validateVehicaltype)
  98. {
  99.  
  100. calcParkingfee = parkingTime * validateVehicaltype
  101.  
  102. return ()
  103. }
  104.  
  105. /* Show Parking Fee With 'float' Precision, to Two Decimal Places */
  106. float showParkingfee (char inputVehicaltype, int validateParkingtime, float calcParkingtime)
  107. {
  108. printf("%c, %d hrs Parking Fee: $%f\n");
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment