Advertisement
waywtc123

Untitled

Dec 10th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. def readSpools(mode):
  2. if mode == 'a':
  3. spools = int(input('Enter the number of spools ordered: '))
  4. while spools < 1:
  5. print('Please enter a positive amount of spools.')
  6. spools = int(input('Enter the number of spools ordered: '))
  7. if mode == 'b':
  8. spools = int(input('Enter the number of spools in stock: '))
  9. while spools < 1:
  10. print('Please enter a positive amount of spools.')
  11. spools = int(input('Enter the number of spools in stock: '))
  12. return spools
  13.  
  14.  
  15. def readDeliveryOption():
  16. selection = input('Do you prefer rush or normal delivery?: ')
  17. while selection != 'rush' and selection != 'normal':
  18. print('Please enter either rush or normal.')
  19. selection = input('Do you prefer rush or normal delivery?: ')
  20. return selection
  21.  
  22.  
  23. def readyToShip(a, b):
  24. if a < b:
  25. ready = a
  26. else:
  27. ready = b % a
  28.  
  29. return ready
  30.  
  31.  
  32. def backOrdered(a, b):
  33. if a < b:
  34. back = 0
  35. else:
  36. back = a % b
  37. return back
  38.  
  39. def shippingCharges(a, b):
  40. shippingCost = a * b
  41. total = a * 100 + shippingCost
  42. return shippingCost, total
  43.  
  44.  
  45. def main():
  46. option = input('Do you want to continue processing spools order status (Y/N): ').upper()
  47. while option != 'Y' and option != 'N':
  48. print('Please enter either Y or N')
  49. option = input('Do you want to continue processing spools order status (Y/N): ').upper()
  50. while option == 'Y':
  51. spoolsOrdered = readSpools('a')
  52. spoolsStock = readSpools('b')
  53. deliveryMode = readDeliveryOption()
  54. spoolsReady = readyToShip(spoolsOrdered, spoolsStock)
  55. spoolsBack = backOrdered(spoolsOrdered, spoolsStock)
  56. if deliveryMode == 'rush':
  57. shippingRate = 15.00
  58. else:
  59. shippingRate = 10.00
  60. shippingCost, totalCost = shippingCharges(spoolsReady, shippingRate)
  61. print('Spools ready to ship: ' + str(spoolsReady))
  62. print('Spools on back order: ' + str(spoolsBack))
  63. print(format('Shipping and handling:', '24s') + '$' + format(shippingCost, '.2f'))
  64. print(format('Total due:', '24s') + '$' +format(totalCost, '.2f'))
  65. option = input('Do you want to continue processing spools order status (Y/N): ').upper()
  66. while option != 'Y' and option != 'N':
  67. print('Please enter either Y or N')
  68. option = input('Do you want to continue processing spools order status (Y/N): ').upper()
  69.  
  70.  
  71. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement