akosiraff

Fireworks Checkout Stand

Mar 5th, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. Download: http://solutionzip.com/downloads/fireworks-checkout-stand/
  2.  
  3. Previous Weeks scenario
  4.  
  5. Scenario:
  6. Your algorithm will keep track of a customer’s purchases at the local fireworks stand. Customers will
  7. not know exactly how many items they will purchase, so using a FOR loop on this lab is not allowed.
  8. Let’s keep the rules simple.
  9. 1) Accept the dollar value of each item purchased from the user until the useris finished.
  10. 2) When purchases are complete, enter a sentinel value of -1. (Make certain you do not
  11. include the -1 sentinel value in your total).
  12. 3) Keep track of the total dollar amount of all fireworks purchased.
  13. 4) Keep a tally of the number of items purchased.
  14. 5) If more than 20 items were purchased, give your customer a 10% discount on their total
  15. purchases.
  16. 6) Once purchases are complete, display the total number of items purchased, the average
  17. price of the items, the total of all fireworks purchased, any discount if applicable & the
  18. total of all fireworks purchasedminus the discount.
  19.  
  20.  
  21. Previous Pseudo code/IPO Chart
  22. IPO Chart:
  23. INPUT PROCESSING OUTPUT
  24. Array Purchase(100) Count=0
  25. WHILE Purchase(Count) <> -1
  26. Count = Count + 1
  27. Input “Please enter item price (-1 when
  28. finished) : “ = Purchase(Count)
  29. IF Purchase(Count) <>-1 then
  30. Sum = Sum + Purchase(Count)
  31. ENDIF
  32. ENDWHILE
  33. Count = Count – 1 //To remove ‘-1’ as item
  34. OUTPUT “________”
  35. OUTPUT “________”
  36. OUTPUT “Total items purchased: “ & Count
  37. OUTPUT “The average price of items: “ & FormatCurrency(Average)
  38. OUTPUT “The SubTotal is: “ & FormatCurrency(Sum)
  39.  
  40. IF Count>20
  41. Total = Sum*.90
  42. Discount = 1
  43. ELSE Total = Sum
  44. ENDIF
  45. IF Discount=1 then
  46. Discount = total-Sum
  47. OUTPUT “Amount saved: “ &
  48. FormatCurrency(Discount)
  49. ELSE OUTPUT “You did not qualify for a discount today.”
  50.  
  51. Average = Sum/Count OUTPUT “Total: “ & FormatCurrency(Total)
  52.  
  53.  
  54.  
  55. Pseudo code:
  56. Begin fireworkstore
  57. Declare Real Purchase(100)
  58. Declare Real Count
  59. Declare Real Average
  60. Declare Real Total
  61. Declare Real Sum
  62. Declare Real Discount
  63. Set Count = 0
  64. WHILE Purchase(Count) <> -1
  65. Count = Count + 1
  66. INPUT “Please enter item price (-1 when finished) : ” = Purchase(Count)
  67. IF Purchase(Count) <> -1
  68. Sum = Sum + Prchase(Count)
  69. ENDIF
  70. ENDWHILE
  71. Count = Count – 1 //This ensures that the item count is correct and ‘-1’ is not counted
  72. IF Count>20
  73. Total = Sum * .90
  74. Discount = 1
  75. ELSE
  76. Total = Sum
  77. ENDIF
  78. Average = Sum / Count
  79. OUPUT “__________________________________”
  80. OUPUT “__________________________________”
  81. OUTPUT “Total items purchased: “ & Count
  82. OUTPUT “The average price of items: “ & FormatCurrency(Average)
  83. OUTPUT “The SubTotal is : “ & FormatCurrency(Sum)
  84. IF Discount =1 THEN
  85. Discount = Total – Sum
  86. OUTPUT “Amount Saved : “ & FormatCurrency(Discount)
  87. ELSE
  88. OUTPUT “You did not qualify for a discount today.”
  89. ENDIF
  90. OUTPUT “Total : “ & FormatCurrency(Total)
  91. End
  92.  
  93. Download: http://solutionzip.com/downloads/fireworks-checkout-stand/
Advertisement
Add Comment
Please, Sign In to add comment