CS problem

profileSwagman888
assignment7_instructions.pdf

1

CS 170 ‐ Computer Applications for Business

Fall 2016 ‐ Assignment 7

JavaScript Event-Driven Programming

Due Date Before 11:00 PM - Friday, October 28th, 2016

Accept Until Before 11:00 PM - Friday, November 4th, 2016

Evaluation 15 points

Submit to Sakai Assignment7_answers.html file

To get credit for this assignment:

Upload and submit the Assignment7_answers.html file through Sakai.

Learning Objectives:

This assignment is designed to practice:

1. Understand the basic input and output mechanisms of dynamic web applications from

the code perspective

2. Implement JavaScript code which will handle user events

3. Display feedback of said processed interactions back to the user

4. Practice your understanding of basic JavaScript from the prior Assignment

a variables, including;

i The declaration, initialization and assignment processes

b Use of the conditional if statements

c Use of arithmetic and logic operators

d Use of comments

Directions:

You are provided an HTML program. Your responsibility is to insert the HTML tags with the

appropriate JavaScript statements that will solve the problem discussed below, and to

comment the html file with the requested information per the requirements. The problem

description and HTML program provided are slightly different from Assignment 6. Be sure to

start fresh.

2

Problem to solve:

The Serendipity Booksellers has a book club that awards points to its customers based on the

number of books purchased each month. The points are awarded as follows:

 If a customer purchases 0 books, they earn 0 points

 If a customer purchases 1 book, they earn 4 points

 If a customer purchases 2 books, they earn 8 points

 If a customer purchases 3 books, they earn 16 points

 If a customer purchases more than 3 books, they earn an additional 7 points on top of

the 16 points for each book above 3.

Serendipity Booksellers also awards points based on the dollar value spent on non-book

merchandise. Four (4) points are awarded for every $10 spent. Partial awards are not provided.

For example, 4 points will be awarded for spending $10.00 up to $10.99. No points are awarded

for less than $10.

Preferred Customers receive a bonus of double award points.

The Serendipity Booksellers website needs to be updated to ask the customer to enter the

number of books purchased last month, the dollars spent on non-book merchandise, confirm if

they are a Preferred Customer, and then calculate and display the number of award points

earned.

Requirements:

For this assignment; 1. Your program will calculate the award points as described above. 2. You will generate HTML comments to add your name, section and TA name. Each on a

separate line within the <Head> tags. This will (should) NOT be visible in the document on the web browser).

3. Utilize a <form> tag 4. You will then add the HTML tags with the proper JavaScript code to produce:

a. A textbox to solicit the number of books purchased b. A textbox to solicit the dollars of non-book merchandise c. Grouped radio buttons to determine Preferred Customer membership d. A button to calculate the number of points awarded e. A readonly textbox to display the result the calculation

5. Utilize JavaScript comments to explain the steps you are preforming within your code. A

JavaScript comment’s form is:

/* Place your comment between the stars */

3

6. Variable names should be descriptive. For example, if a program is calculating the total

charge for a bill at a restaurant, it may have a variable named tipAmount.

7. Utilize at least one if/else statement. Consider using the if/else in determining the

bonus points.

A sample of what your webpage could look like:

Additional Information:

Since the contents of a textbox, is going to be used in mathematical operations. Textboxes

sometimes treat input as Strings. Use the function parseInt() to convert the String text to a

number. Otherwise your calculation operations will not perform as expected.

JavaScript provides several math utilities. The Math.floor() method rounds a number

DOWNWARDS to the nearest integer, and returns the result.

References:

Fluency 6 - Chapter 17 - Fundamental Concepts Expressed in JavaScript

- Chapter 18 – A JavaScript Program

w3schools.com - http://www.w3schools.com/js/default.asp

Firefox Tools - https://developer.mozilla.org/en-US/docs/Tools/Debugger

Lectures’ slides and examples

Recitation Week 6

Recitation Week 7