Part 1: The Structure of the Web

In lecture and in our reading we discussed the structure of the Web. In this part, you are asked to complete this questionnaire and you recognize the components of a Web-like graph.

Note that you have to complete the questionnaire individually.

Part 2: JS Functions

The purpose of this assignment is to help you improve your skills with JavaScript, specifically you will get practice with functions.

You also have to complete this part individually.

Task 0: Set up and preparation

Download a zipped copy of the hw5 starting folder onto your Desktop and open it by double-clicking on it. This folder contains:

  • an html document named assign5.html, that you should not modify, and
  • a JavaScript file assign5JS.js, in which you will add your code.
Open assign5.html in your text editor and examine the code. You will see that two text inputs and a button have been set up there. The user enters her input in the text inputs, and once she clicks on the button the results are presented on the page. If you load this page in your browser, you will see that the page does not responde to the user's clicks at this point. Can you tell why?
Your code will change this behaviour.

Experiment with this sample page to see how your final program should behave.

Task 1: Function breakMoney()

Write the definition of the function breakMoney(amount, bill) which takes two arguments:

  • An amount to be broken into bills, and
  • a bill denomination to use in breaking the amount.

The function breakMoney(amount, bill) should do the following:

  • Compute the number of bill denominations needed to break the amount, and the remaining amount.
  • Show a nice message on the web page (assign5.html) informing the user about the results of the computation.

For example, breakMoney(112, 20) should compute that five 20-dollar bills are needed to break this amount, while the remainder is $12 (because 120 = 5*20 + 12)

You should test your code with several different inputs by calling it from the Javascript Console in your browser, as we did in the previous labs, until you are certain it works correctly.

Task 2: Function updatePage()

Define this function so that it reads the user's inputs from the web page (assign5.html) and then calls the breakMoney() accordingly to do the calculations and present the results.


When you are ready to upload, your folder should contain the assign5.html and the assign5JS.js files.

Important Note

You must upload your hw5 folder to your cs115-assignments folder, which is a subfolder of your public_html one, on the cs server. Your cs115-assignments folder has permissions set so that only you and the instructors/graders can see your work.

Make sure you check the page using the URL once you've uploaded:

When you visit the page, because it is protected, you will be prompted for a username and password. You should use your own account name and password for the CS server.

Coding Style

All the usual coding rules apply. See the style rules. Indent properly, use white space to make code more readable, and use comments to explain what effects is being achieved by a rule.

Due Date/Time

Remember that assignments may not be turned in late. This assignment is due at 11:59pm on the due date (check the schedule). Furthermore, remember that this policy means that you should not modify turned in work after the due time has passed, so that when we grade it, it's not time-stamped late.

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. You should not be looking at other peoples' code or showing them yours. If you worked with others or you have obtained help from any source, you must acknowledge their contribution in writing.

Homework assignments must be your own work. You may not look at solutions from other students, either from the current offering or from past offerings.


These are the criteria we use to grade the homework:

  • Homework was submitted on the server by the due date. Late submissions receive 0 points.
  • Folders and files have the required names and are uploaded to the proper location.
  • Your files have comments at the top and as necessary interspersed in the code.
  • Your code follows our recommended coding style.
  • You have not modified the original HTML page.
  • The JS code produces correct results for any input.

Help Room

Our tutors in the help room can help you with concrete problems and questions you have about the assignment, thus, go to the room prepared. If you find that you don't know how to start the assignment, you should visit the instructors during their office hours.