Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Download: http://solutionzip.com/downloads/fireworks-checkout-stand/
- Previous Weeks scenario
- Scenario:
- Your algorithm will keep track of a customer’s purchases at the local fireworks stand. Customers will
- not know exactly how many items they will purchase, so using a FOR loop on this lab is not allowed.
- Let’s keep the rules simple.
- 1) Accept the dollar value of each item purchased from the user until the useris finished.
- 2) When purchases are complete, enter a sentinel value of -1. (Make certain you do not
- include the -1 sentinel value in your total).
- 3) Keep track of the total dollar amount of all fireworks purchased.
- 4) Keep a tally of the number of items purchased.
- 5) If more than 20 items were purchased, give your customer a 10% discount on their total
- purchases.
- 6) Once purchases are complete, display the total number of items purchased, the average
- price of the items, the total of all fireworks purchased, any discount if applicable & the
- total of all fireworks purchasedminus the discount.
- Previous Pseudo code/IPO Chart
- IPO Chart:
- INPUT PROCESSING OUTPUT
- Array Purchase(100) Count=0
- WHILE Purchase(Count) <> -1
- Count = Count + 1
- Input “Please enter item price (-1 when
- finished) : “ = Purchase(Count)
- IF Purchase(Count) <>-1 then
- Sum = Sum + Purchase(Count)
- ENDIF
- ENDWHILE
- Count = Count – 1 //To remove ‘-1’ as item
- OUTPUT “________”
- OUTPUT “________”
- OUTPUT “Total items purchased: “ & Count
- OUTPUT “The average price of items: “ & FormatCurrency(Average)
- OUTPUT “The SubTotal is: “ & FormatCurrency(Sum)
- IF Count>20
- Total = Sum*.90
- Discount = 1
- ELSE Total = Sum
- ENDIF
- IF Discount=1 then
- Discount = total-Sum
- OUTPUT “Amount saved: “ &
- FormatCurrency(Discount)
- ELSE OUTPUT “You did not qualify for a discount today.”
- Average = Sum/Count OUTPUT “Total: “ & FormatCurrency(Total)
- Pseudo code:
- Begin fireworkstore
- Declare Real Purchase(100)
- Declare Real Count
- Declare Real Average
- Declare Real Total
- Declare Real Sum
- Declare Real Discount
- Set Count = 0
- WHILE Purchase(Count) <> -1
- Count = Count + 1
- INPUT “Please enter item price (-1 when finished) : ” = Purchase(Count)
- IF Purchase(Count) <> -1
- Sum = Sum + Prchase(Count)
- ENDIF
- ENDWHILE
- Count = Count – 1 //This ensures that the item count is correct and ‘-1’ is not counted
- IF Count>20
- Total = Sum * .90
- Discount = 1
- ELSE
- Total = Sum
- ENDIF
- Average = Sum / Count
- OUPUT “__________________________________”
- OUPUT “__________________________________”
- OUTPUT “Total items purchased: “ & Count
- OUTPUT “The average price of items: “ & FormatCurrency(Average)
- OUTPUT “The SubTotal is : “ & FormatCurrency(Sum)
- IF Discount =1 THEN
- Discount = Total – Sum
- OUTPUT “Amount Saved : “ & FormatCurrency(Discount)
- ELSE
- OUTPUT “You did not qualify for a discount today.”
- ENDIF
- OUTPUT “Total : “ & FormatCurrency(Total)
- End
- Download: http://solutionzip.com/downloads/fireworks-checkout-stand/
Advertisement
Add Comment
Please, Sign In to add comment