Overview

The purpose of this assignment is to get you to think again about number systems and to get some practice writing basic JavaScript code.

Notice that Task 1 is an individual assignment, while Task2 is a paired-programming one.

Part 1: On Number Systems

individual part

Please answer the questions in this document.

Part 2: JavaScript programming

Pair programming part

On this part, you and your partner will be pair-programming basic JavaScript.

Pair programming, as you have experienced it in lab, is an agile software development technique in which two programmers (or students) work together sharing one computer. One student is the driver, who controls the keyboard and mouse. The other is the navigator, who observes, asks questions, suggests solutions, and thinks about slightly longer-term strategies. The two programmers switch roles about every 20 minutes.
Working in pairs should make you much better at programming than would working alone. Research shows that the resulting work of pair programming nearly always outshines that of the solitary programmer, with pairs producing better code in less time.

To learn the do’s and don’ts of pair programming and to see pairs in action, view this entertaining video about pair programming from North Carolina State University: An Introduction to Pair Programming for Students.

(The above information about pair programming is adapted from NCWIT)

Forming teams

Use this team-forming shared document to form and declare teams.

Set up and preparation

Download a zipped copy of the hw02 starting folder onto your Desktop and open it by double-clicking on it. This folder contains a file bookstore.html, which you will use for this part of the assignment.

Start by opening the file in a word editor (like Textwrangler) and edit the top of the file comments to include your names and the rest of the information.

Your task

You will calculate costs for purchasing books and magazines, using some simple JavaScript input, output, arithmetic, and conditional statements.

Put your JavaScript code within the bookstore.html itself, using the start and end script tags. First read the whole description and look at the images below. Your code should do the following:

  • Prompt the user for the number of books to order. Set the default value to 100.
  • Prompt the user for the number of magazines to order. Set the default value to 20.
  • If the number of books ordered is less than 25, charge $50 per book; otherwise, charge $40 per book.
  • If the number of magazines ordered is less than 25, charge $15 per magazine; otherwise, charge $10 per magazine.
  • Charge a shipping fee of $25 if the total order is under $500. Shipping is free if the total order cost $500 or more.
  • Output this information:
    1. the number of books ordered
    2. the price per book
    3. the number of magazines ordered
    4. the price per magazine
    5. the total number of items
    6. the total cost (without shipping)
    7. the total cost (including shipping)
  • Display that information in the console and on the page. bookstore.html contains a skeleton for displaying this information.
  • Finally, there are two questions, about testing your code, in the comments. Make sure to answer these questions. Add your answers on the page as comments.

Here is the what your page should look like when prompting for an input and then displaying the results:

prompt for input display output

Submit your work by uploading hw02 folder in your public_html/cs115-assignments folder, in your directory. Notice that although this is a pair-programming task, both partners need to upload the work to their individual accounts.

Once you've uploaded your work, make sure you check the page on the browser using this URL :

 http://cs.wellesley.edu/~yourName/cs115-assignments/hw02/bookstore.html

(Of course substitute "yourName" with your own account name.)

When you visit the page, because this is in a protected directory, you will be prompted for a username and password. Use your own login name and password for your account on the CS server.

It is not required to validate your code, but you can do so if you wish to.

Due Date/Time

Assignments are due at 11:59PM on the due date (check the schedule). Remember that this policy means that you should not modify work after the due time has passed.

Honor Code

The Honor Code applies to this course. You are encouraged to discuss assignments with other students, the tutors, and with your instructors. However, you must solve, write up, debug, test and document the assignment on your own . In other words, it is acceptable to talk with other students in English (or any other human language), but not acceptable to use any formal language and especially not HTML, CSS or JavaScript with other student. You should not be looking at other's code or showing them yours. If you have obtained help from any source, you must acknowledge their contribution in writing, as comment on the page.

Grading

These are the criteria we use to grade the homework:

  • Homework was submitted on the server by the due date.
  • Folders and files have the required names and are uploaded to the proper location.
  • Files are commented at the top, and as necessary interspersed in the code.
  • Your code follows our recommended coding style.
  • Questions are answered as described above.
  • Correctness of the calculations and the display.