deadlyhunter88

Untitled

Apr 30th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Design Specifications
  2. Write, compile and test a C program with appropriate user-defined functions (modular design)
  3. and comments to calculate parking fee. The program must meet the following specifications:
  4. a) Prompt the user to input the vehicle type. ‘c’ or ‘C’ for a car, ‘m’ or ‘M’ for a motorbike, ‘t’
  5. or ‘T’ for a truck. Display a message 'Wrong vehicle typewhen the input character is
  6. other than specified.
  7. b) Prompt the user to input the parking time in hours. The parking time is supposed to be a
  8. positive integer number greater that 0 and less or equal to 24. Therefore, one hour
  9. minimum charge is applied. The program should validate the input time.
  10. The program should display a message 'Wrong parking time when the entered time is not
  11. positive,or Parking time is limited to 24 hrswhen the entered parking time is >24. If the
  12. entered time is not an integer number (for example 5.3) it must be rounded up (to 6 in this
  13. example).
  14. c) Calculates the amount charged based upon the following rates:
  15. car - $3.50 p/h, motorbike - $1.50 p/h, truck - $8.00 p/h
  16. However, if parking time is longer than 3 hrs, a 20% discount rate is applied (after 3 hrs).
  17. If parking time is longer than 10 hrs, a 40% discount is applied (after 10 hrs )
  18. Output the parking time and the parking fee only for the defined vehicle types as shown
  19. in the examples.
  20. Coding Requirements
  21. Your program must meet the following coding requirements:
  22. a) The parking hourly rates, the discount time thresholds (3 and 10), the discount rate
  23. coefficients (0.2 and 0.4) have to be defined as constants
  24. b) Use bool type ( defined in stdbool.h) to represent logical values trueand false
  25. c) Your program must have at least the following user-defined functions
  26. inputParkingTime (…)Prompt the user to enter the parking time. If the
  27. entered value is not integer, round it up. Return the
  28. obtained integer value
  29. validateVechileType (…)Get the vehicle type as a parameter; validate vehicle
  30. type; if the type is valid, the function returns true,
  31. otherwise, it returns false. The function must not
  32. print any messages on the screen
  33. validateParkingTime(…)Get the parking time as a parameter; validate the
  34. parking time; if the time is valid (0<time<=24), the
  35. function returns 0; if it is ≤0 it returns -1; if it is > 24 it
  36. returns 1. The function must not print any messages
  37. on the screen
  38. calculateParkingFee(…)the function returns the parking fee. The function must
  39. not print any messages on the screen
  40. showParkingFee(…)the function outputs the parking fee with the two
  41. decimal point precision in a format shown in the
  42. example
  43. You need to define appropriate formal parameters and return type for each function.
  44. Make sure that you do not use global variables.
  45.  
  46. Having been run, your program should produce output formatted as shown below
  47. (the actual numbers may be different ):
  48. Example1:
  49. Enter your vehicle type (C, M or T): c
  50. Enter parking time (hours): 2
  51. Car 2 hrs parking fee: $7.00
  52. Example2:
  53. Enter your vehicle type (C, M or T): K
  54. Wrong vehicle type
  55. Example3:
  56. Enter your vehicle type (C, M or T): t
  57. Enter parking time (hours): -7
  58. Wrong parking time
  59. Example4:
  60. Enter your vehicle type (C, M or T): T
  61. Enter parking time (hours): 26
  62. Parking time is limited to 24 hrs
  63. Example5:
  64. Enter your vehicle type (C, M or T): T
  65. Enter parking time (hours): 4.2
  66. Truck 5 hrs parking fee: $36.80
Advertisement
Add Comment
Please, Sign In to add comment