Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def readSpools(mode):
- if mode == 'a':
- spools = int(input('Enter the number of spools ordered: '))
- while spools < 1:
- print('Please enter a positive amount of spools.')
- spools = int(input('Enter the number of spools ordered: '))
- if mode == 'b':
- spools = int(input('Enter the number of spools in stock: '))
- while spools < 1:
- print('Please enter a positive amount of spools.')
- spools = int(input('Enter the number of spools in stock: '))
- return spools
- def readDeliveryOption():
- selection = input('Do you prefer rush or normal delivery?: ')
- while selection != 'rush' and selection != 'normal':
- print('Please enter either rush or normal.')
- selection = input('Do you prefer rush or normal delivery?: ')
- return selection
- def readyToShip(a, b):
- if a < b:
- ready = a
- else:
- ready = b % a
- return ready
- def backOrdered(a, b):
- if a < b:
- back = 0
- else:
- back = a % b
- return back
- def shippingCharges(a, b):
- shippingCost = a * b
- total = a * 100 + shippingCost
- return shippingCost, total
- def main():
- option = input('Do you want to continue processing spools order status (Y/N): ').upper()
- while option != 'Y' and option != 'N':
- print('Please enter either Y or N')
- option = input('Do you want to continue processing spools order status (Y/N): ').upper()
- while option == 'Y':
- spoolsOrdered = readSpools('a')
- spoolsStock = readSpools('b')
- deliveryMode = readDeliveryOption()
- spoolsReady = readyToShip(spoolsOrdered, spoolsStock)
- spoolsBack = backOrdered(spoolsOrdered, spoolsStock)
- if deliveryMode == 'rush':
- shippingRate = 15.00
- else:
- shippingRate = 10.00
- shippingCost, totalCost = shippingCharges(spoolsReady, shippingRate)
- print('Spools ready to ship: ' + str(spoolsReady))
- print('Spools on back order: ' + str(spoolsBack))
- print(format('Shipping and handling:', '24s') + '$' + format(shippingCost, '.2f'))
- print(format('Total due:', '24s') + '$' +format(totalCost, '.2f'))
- option = input('Do you want to continue processing spools order status (Y/N): ').upper()
- while option != 'Y' and option != 'N':
- print('Please enter either Y or N')
- option = input('Do you want to continue processing spools order status (Y/N): ').upper()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement