Computer Applications for Business
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CS170 – Computer Applications for Business
PROBLEM DESCRIPTION
The owner of Mandy’s Restaurant wants to automate payment. In an attempt to do that, you are
asked to build a webpage that collects information and displays certain results.
A customer visits Mandy’s Restaurant for dinner and determines the total amount owed for the dinner
following the rules listed below.
• There is always 7% sales tax that will be added to the total amount spent on food and beverages.
• A gratuity (tip) is always added to the total based on the quality of service received. Quality of
service is a rating from 0 – 10. Assume that the value entered is a number between 0 and 10
inclusive.
o If the service is POOR (a rating from 0 to 2 inclusive) the customer leaves a tip of 10% of the
total amount spent on food and beverages.
o If your service is AVERAGE (a rating from 3 to 6 inclusive), the customer leaves a tip of 15%
of the total amount spent on food and beverages.
o If your service is GOOD (a rating from 7 to 10 inclusive), the customer leaves a tip of 20% of
the total amount spent on food and beverages.
• If the customer has a Mandy’s reward card then:
o If the balance on the rewards card is less than or equal to the amount owed, the card
balance is subtracted from the amount owed and the card balance is set to 0;
o If the balance on the rewards card is greater than the amount owed, the dinner is free and
the card balance is appropriated updated by subtracting the dinner cost from the card
balance.
The inputs you need (USE PROMPT):
The amount spent on food and beverages.
The quality of service (a number between 1 and 10).
Whether or not the customer has a rewards card (yes or no). If the customer has a rewards card then the
current balance on the rewards card is also input.
You are to display the following (use ALERT):
Display the tax amount added to the bill.
Display the tip amount added to the bill.
Display the updated rewards card balance if the customer has a rewards card.
Display the amount of the total bill that the customer will pay.
Follow the sequence of input/output steps below:
1. Prompt to get cost of food and beverages.
2. Alert to display tax amount added to bill
3. Prompt to get the quality of service rating (a number between 0 and 10 inclusive). You can assume
the values entered here are all within range.
4. Alert to display the tip amount.
5. Prompt inquiring whether or not the customer has a Valued Customer Card (yes/no). You can
assume the person will enter either yes or no.
6. If the customer has a Valued Customer Card, prompt to ask the card balance.
Page 3 of 4
7. If the customer has a Valued Customer Card, do the math as described in the problem above and
display in an Alert the new balance on the Valued Customer Card.
8. Display in an Alert the total amount owed by the customer.
SAMPLE TRACES THROUGH THE CORRECT ALGORITHM
Sample1:
Meal cost = 100
Service rating = 3
Reward card balance = 32.50
OUTPUT:
Tax = $7.00
Tip = $15.00
New Card Balance = $0
Total amount for dinner =
$89.50
Sample2:
Meal cost = 52
Service rating = 9
Reward card balance = 95
OUTPUT:
Tax = $3.64
Tip = $10.40
New Card Balance = $28.96
Total amount for dinner =
$0.00
Sample 3
Meal cost = 42.00
Service rating = 5
No rewards card
OUTPUT
Tax = $2.94
Tip = $6.30
Total amount for dinner =
$51.24
Additional Information:
• Since the content of a text box – which is what the prompt() function generates – is going to
be used in mathematical operations, use the function Number() to ensure that the numeric
input is treated as numeric data.