INF 286 John Tyler Community College Write A HTML Page Computer Coding Task
Description
Coding questions. The following question needs your complete HTML code.
Problem 1 (70%): Using JavaScript, create a simple web page that will take orders for Chess Org. Chess Org sells yearly membership for $30 each. Discounts are given for buying in bulk (see Table 1 and example below).
Table 1 -Discounts
Quantity Purchased
Discount
1-29
0%
30-59
10%
60 or above
15%
Example: If a customer purchases 40 family membership, their total price (CTotalPrice) would be:
COriginalPrice = 30*40=1200
DMainDiscount = 1200*0.1=120
CTotalPrice = COriginalPrice – DMainDiscount = 1200-120 = 1080
You need to write a web page that asks the user for the user info and order info, display the user info and order info, and then ask the user whether to run the application again. If yes, then re-run the program.
Program Requirements: Your program must be written in JavaScript. In addition, you should follow the specific guidelines below.
(15%) Use the prompt dialog to collect the user input, including:
name,
mailing address,
phone number,
email address and
the number of memberships that the user purchases ( 10% make sure to collect a valid number 0 – 100. Keep asking the user to input the number until receiving a valid number from 0 – 100).
(2.5%) Use JavaScript to output a line of heading 3 text (with the tag <h3>) showing text of Customer Information for UserName. Here the UserName is the user name collected above.
(5%) Use JavaScript to output the following Customer Information right below the heading 3 text Customer Information for UserName above, including:
User’s name (2.5%),
User’s address (2.5%),
User’s phone number (2.5%), and
User’s email address (2.5%).
(2.5%) Use JavaScript to output a line of heading 3 text (with the tag <h3>) showing text of Order Information for UserName. Here the UserName is the user name collected above.
(20%) Use JavaScript to output the following Order Information right below the heading 3 text Order Information for UserName above, including:
Number of memberships purchased and cost per membership (5%),
Total cost before discount (5%),
Amount of discount (5%)
Total cost after discount (5%).
(10%) Ask the user the question about whether the user wants to purchase memberships: if not, display an appropriate message on an alert dialog and stop the program; if yes, restart the process from Step 1 to Step 5. The program will stop until the user replies NO to the question whether to purchase memberships (hint: use the do – while loop).
(15%) format the output of the user information and the order information so that they are well formatted: Hint:
Use the css rules to format the output so that the text label (e, g, User name: ) for each data output is aligned to the right, and the data output (e. g. Hongmei) is aligned to the left, Or
Write the text label and the data output in a two-column table
An example page output is given below.
The contents of the example page above are displayed below with use of tables:
Customer Information for Hongmei:
Name:
Hongmei
Address:
1 Nunn Dr. Highland Heights, KY 41099
Phone number:
(859) 572-7786
Email:
Wangh1@nku.edu
Order Information for Hongmei:
Number of membership purchased:
40
Cost per membership:
$30
Total cost before discount:
$1200
Discount:
10% / $120
Total cost after discount:
$1080
Thanks for using our order application!
Customer Information for Rachel:
Name:
Rachel
Address:
- 3 Nunn Dr. Highland Heights, KY 41099
- Phone number:
- (859) 572-7785
- Email:
panr1@nku.edu
Order Information for Rachel:
- Number of membership purchased:
90
Cost per membership:
- $30
- Total cost before discount:
- $2700
Discount:
- 15% / $405
Total cost after discount:
$2295
Thanks for using our order application!
- Problem 2 (30%): Using JavaScript to write a HTML page:
- to create an array with 100 elements (5%);
- assign each of the first 50 elements with a value which equals to its subscript; (2.5%);
- assign each of the last 50 elements with a value which equals to the addition of its subscript and 2; (2.5%);
- Calculate the sum and the average of all element values in the array (5%);
- Use a table to display the subscript, element value of each element in the array; (10%);
Hint: write the opening table tag and the first row showing the table headings (first one is for subscript and the second is for element value) into the document.
- Then use a for loop to write each table row of HTML tags and text into the page document.
- for(var i = 0; i < array1.length; i++)
{
document.writeln( “<tr><td>” + i + “</td><td>” +
array1[i] + “</td>”+ “</td></tr>”);
}
Then write the closing table tag into the document.
Display the sum and the average of the elements in the array;
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."