Part 1) The pseudocode will be written in a Document file (Word, WordPad, etc.).
ID: 3753568 • Letter: P
Question
Part 1) The pseudocode will be written in a Document file (Word, WordPad, etc.). Write a pseudocode for the following problem before you write your Raptor code. Part 2) Use Raptor for the following problem helping a local restaurant in their check processing. We like to process a set of restaurant checks/bills. Ask for the number of checks. Make sure the user inputs a positive number more than 0 for the number of checks. You need to continue asking for a valid number of checks until valid data is entered. For each check, in the following order, ask for the name of the server, the amount of check, the number of patrons for the check and the day of the week (Monday, etc.). If the number of patrons is 8 or less, tip is 15% of the check. If the number of patrons is more than 8, tip is 18% of the check. If the day of the week is tuesday, apply a 10% discount to the grand total amount of the check. You can assume that the day of the week is always entered in lower case. Assume the tax rate is 8.5%. Note that the tip and the tax are calculated based on the original bill amount. a) b) c) d) Calculate and display the grand total of all checks. e) Calculate and display the grand total of all discount amounts.Explanation / Answer
EXPLAINATION
The first problem is that we have to ask the user for a valid number of checks until we get a number greater than 0. We achieve this using while loop (Steps 1 to 3).
The second problem is we want to get the input from the user for server, amount, no of patrons and day. We do that using a loop that runs for all the checks and we store them in different arrays. (Steps 6 to 10)
The third problem is, we want to find out tax and tip for each check. Tax is the same for all checks (8.5%) but the tip is different depending on the number of patrons. We use IF ELSE block to achieve that. (Steps 11 to 16)
The fourth problem is, we want to give a discount only on Tuesdays, that is also achieved using an IF block. (Steps 17 to 21)
At the end of each loop, we update the grand total amount and grand total discount so that we can display them at the end of the code. (Steps 22 and 23)
In steps 25 and 25, we finally display the amounts.
PSEUDOCODE:
Step 1. noOfChecks = INPUT("Enter the number of checks")
Step 2. WHILE noOfChecks <= 0 repeat step 3
Step 3. noOfChecks = INPUT("You need to enter a positive number")
[END LOOP]
Step 4. Make arrays server[noOfChecks], amount[noOfChecks], noOfPatrons[noOfChecks], day[noOfChecks], discount[noOfChecks]
Step 5. SET i = 0, grandTotal = 0, totalDiscount = 0
Step 6. WHILE i < noOfChecks repeat steps 7 to 24
Step 7. server[i] = INPUT("Enter name of the server")
Step 8. amount[i] = INPUT("Enter the amount of check")
Step 9. noOfPatrons[i] = INPUT("Enter the number of patrons for the check")
Step 10. day[i] = INPUT("Enter the day of the week")
Step 11. SET tax = 8.5 * amount[i] / 100
Step 12. IF noOfPatrons[i] <= 8
Step 13. THEN SET tip = 15 * amount[i] / 100
Step 14. ELSE
Step 15. SET tip = 18 * amount[i] / 100
[END IF]
Step 16. SET amount[i] = amount[i] + tip + tax
Step 17. IF day[i] == "tuesday" THEN
Step 18. discount[i] = 10 * amount[i] / 100
Step 19. amount[i] = amount[i] - discount[i]
Step 20. ELSE
Step 21. discount[i] = 0
[END IF]
Step 22. grandTotal = grandTotal + amount[i]
Step 23. totalDiscount = totalDiscount + discount[i]
Step 24. SET i = i + 1
[END LOOP]
Step 25. PRINT grandTotal
Step 26: PRINT totalDiscount