Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. 1. calculateShippingCost
  2. global totalDistance
  3. global shippingCost
  4.  
  5. output (Enter the distance in miles:)
  6. input (totalDistance)
  7.  
  8. call validDistance
  9. call calcVariableCosts
  10.  
  11. set shippingCost
  12. shippingCost = shippingCost + 50
  13.  
  14. proc validDistance
  15. if (totalDistance < 0) then
  16.  
  17. output (ERROR: The distance should be a positive value)
  18.  
  19. else
  20. (totalDistance > 0)
  21. endif
  22. endproc
  23.  
  24.  
  25. proc calcVariableCosts
  26. if (totalDistance <= 100)
  27. then
  28. totalDistance * 5.5 = shippingCost
  29. else
  30. if totalDistance > 100 & totalDistance <= 500
  31. then
  32. totalDistance – 100 = n1
  33. 100*5.5 = n2
  34. n1*4 = n3
  35. n2+n3 = shippingCost
  36. else
  37. if totalDistance > 500
  38. then
  39. totalDistance – 100 = n1
  40. n1 – 400 = n2
  41. 100 * 5.5 = n3
  42. 400 * 4.0 = n4
  43. n2 * 2.5 = n5
  44. n3 + n4 + n5 = shippingCost
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement