Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. import sys
  2. '''
  3. Section 1: Collect customer input
  4. '''
  5.  
  6. ##1) Request Rental code:
  7. #Prompt --> "(B)udget, (D)aily, or (W)eekly rental?"
  8. #rentalCode = ?
  9.  
  10. rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n")
  11.  
  12.  
  13. #2) Request time period the car was rented.
  14. rentalPeriod = int()
  15. if rentalCode == 'D':
  16. rentalPeriod = int(input("Number of Days Rented:\n"))
  17. elif rentalCode == 'W':
  18. rentalPeriod = input("Number of Weeks Rented:\n")
  19.  
  20. #Prompt --> "Number of Days Rented:"
  21. #rentalPeriod = ?
  22. # OR
  23. #Prompt --> "Number of Weeks Rented:"
  24. #rentalPeriod = ?
  25.  
  26. #CUSTOMER DATA CHECK 1
  27. #ADD CODE HERE TO PRINT:
  28. #rentalCode
  29. #rentalPeriod
  30. print(rentalCode)
  31. print(rentalPeriod)
  32.  
  33.  
  34.  
  35. #3) Set the base charge for the rental type as the variable baseCharge.
  36. #The base charge is the rental period * the appropriate rate:
  37.  
  38. budgetCharge = 40.00
  39. dailyCharge = 60.00
  40. weeklyCharge = 190.00
  41.  
  42. #baseCharge = ?
  43.  
  44.  
  45. baseCharge = 0
  46. if rentalCode == 'B':
  47. baseCharge = rentalPeriod * budgetCharge
  48. elif rentalCode == 'D':
  49. baseCharge = rentalPeriod * dailyCharge
  50. elif rentalCode == 'W':
  51. baseCharge = rentalPeriod * weeklyCharge
  52. #4)Collect Mileage information:
  53. #a) Prompt the user to input the starting odometer reading and store it as the variable odoStart
  54.  
  55. #Prompt -->"Starting Odometer Reading:\n"
  56. # odoStart = ?
  57. odoStart = input("Starting Odometer Reading:\n")
  58.  
  59. #b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd
  60.  
  61. #Prompt -->"Ending Odometer Reading:"
  62. # odoEnd = ?
  63. odoEnd = input("Ending Odometer Reading:\n")
  64. #CUSTOMER DATA CHECK 2
  65. #ADD CODE HERE TO PRINT:
  66. #odoStart
  67. #odoEnd
  68. #baseCharge
  69. print(odoStart)
  70. print(odoEnd)
  71. print(baseCharge)
  72. '''
  73. Section 2: Calculate the costs from the customer input
  74. '''
  75.  
  76. #1) Calculate the mileage.
  77. #a) Calculate the total mileage:
  78. # ending odometer reading - starting odometer reading
  79. # and store it as the variable totalMiles
  80.  
  81. # totalMiles = ?
  82. totalMiles = int(odoStart + odoEnd)
  83.  
  84. totalCharge = 0
  85. if rentalCode == 'B':
  86. totalCharge = baseCharge + (totalMiles * 0.25)
  87. print(totalCharge)
  88.  
  89. averageDayMiles = 0
  90.  
  91. if rentalCode == 'D':
  92. averageDayMiles = totalMiles/rentalPeriod
  93. if averageDayMiles <= 100:
  94. totalCharge = baseCharge
  95. else:
  96. extraMiles = totalMiles - 100
  97. totalCharge = baseCharge + (extraMiles * 0.25)
  98.  
  99. averageWeekMiles = 0
  100. if rentalCode == 'W':
  101. averageWeekMiles = totalMiles/rentalPeriod
  102. elif averageWeekMiles <= 900:
  103. totalCharge = baseCharge
  104. else:
  105. totalCharge = baseCharge + (rentalPeriod * 100)
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. #2) Calculate the mileage charge and store it as
  113. # the variable mileCharge:
  114.  
  115. #a) Code 'B' (budget) mileage charge: $0.25 for each mile driven
  116.  
  117. #b) Code 'D' (daily) mileage charge: no charge if the average
  118. # number of miles driven per day is 100 miles or less;
  119. # i) Calculate the averageDayMiles (totalMiles/rentalPeriod)
  120.  
  121. # ii) If averageDayMiles is above the 100 mile per day
  122. # limit:
  123. # (1) calculate extraMiles (averageDayMiles - 100)
  124. # (2) mileCharge is the charge for extraMiles,
  125. # $0.25 for each mile
  126.  
  127.  
  128. #c) Code 'W' (weekly) mileage charge: no charge if the
  129. # average number of miles driven per week is
  130. # 900 miles or less;
  131.  
  132. # i) Calculate the averageWeekMiles (totalMiles/ rentalPeriod)
  133.  
  134. # ii) mileCharge is $100.00 per week if the average number of miles driven per week exceeds 900 miles
  135.  
  136.  
  137. '''
  138. Section 3: Display the results to the customer
  139. '''
  140. #1) Calculate the Amount Due as the variable amtDue
  141. # This is the base charge + mile charge
  142.  
  143. #2. Display the results of the rental calculation:
  144.  
  145. #Rental Summary
  146. #Rental Code:
  147. #Rental Period:
  148. #Starting Odometer:
  149. #Ending Odometer:
  150. #Miles Driven:
  151. #Amount Due:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement