JavaScript代写 | CS170 – Computer Applications for Business

本次Javascript代写是实现点餐计费的一个网页
CS170 – Computer Applications for Business
Spring 2020 • Assignment 6
Introduction to JavaScript
Due Date: Before 11:55 p.m. on Friday, March 6th
, 2020
Accept Until: Before 11:55 p.m. on Friday, March 13th
, 2020
Evaluation: 20 points
Submit to Canvas: Assignment6.html file
To earn credit for this assignment:
1. You will create a JavaScript program – embedded on an HTML file – according to the
requirements listed on the next page.
2. Upload and submit a single html file (.html extension) containing the code required.
3. A video of this completed assignment is linked to here; and in FILES→Assignments.
Learning Objectives:
This assignment is designed to practice:
1. Basic understanding of JavaScript variables, including declaration, initialization and
assignment processes.
2. Obtain user input via the prompt() function and present output to the user through the
alert() function.
3. Use of the conditional if and if/else statements
4. Use of arithmetic and logic operators
5. Use of comments
Page 2 of 4
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.
Syntax example:
numericVariable = Number(numericVariable)
• To simplify the comparison of text data entered by the user, it is often easier to convert this
text to upper case using the notation below.
Syntax example:
textVariable = textVariable.toUpperCase();
(See https://www.w3schools.com/jsref/jsref_toUpperCase.asp for additional example.)
• Syntax example for prompt function:
var myName = prompt(“Enter your name”);
• Syntax example for alert function:
alert(“My name is “ + myName);
• Syntax example for displaying a number with a precision of 2 decimals:
alert(“The number is “ + someNumber.toFixed(2));
Page 4 of 4
References:
• Recitation sessions
• Lectures
• Fluency textbook Chapter 17 – Fundamental Concepts Expressed in JavaScript
• w3schools.com – https://www.w3schools.com/js/default.asp
• HTML color names: https://www.w3schools.com/colors/colors_names.asp
• Video of this assignment:
https://rutgers.instructure.com/files/7911632/download?download_frd=1


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论