Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### assign3prep.py
- ### by Rob Marchiselli, Student ID# 2273872, COP1000
- # Pseudocode
- # Request number of pounds desired from user
- # Calculate per_pound rate based on pounds desired
- # Calculate subtotal before tax and shipping
- # Calculate shipping rate based on subtotal (if over $150 it's free)
- # Calculate taxes, order total
- # Print order summary
- def main():
- # Request pounds desired from user
- pounds = float(input('How many pounds are you ordering? '))
- # Determine cost per pound
- if pounds >= 40:
- per_pound = 7.50
- elif pounds >= 20:
- per_pound = 8.75
- elif pounds >= 10:
- per_pound = 10.00
- elif pounds < 10:
- per_pound = 12.00
- # Calculate subtotal before tax and shipping
- subtotal = float(pounds * per_pound)
- # Calculate shipping rate based on order subtotal
- if subtotal > 150:
- shipping = 0
- else:
- ship_rate = 1
- shipping = ship_rate * per_pound
- # Calculate taxes
- tax_rate = float(.07)
- taxes = subtotal * tax_rate
- # Calculate order total
- order_total = subtotal + taxes + shipping
- # Print order summary
- print('How many pounds are you ordering? ',format(pounds,'.0f'),sep='')
- print('Cost of coffee: $',format(subtotal,'.2f'),sep='')
- print('Sales tax (7%): $',format(taxes,'.2f'),sep='')
- print('Shipping fee: $',format(shipping,'.2f'),sep='')
- print('Total payable: $',format(order_total,'.2f'),sep='')
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement