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
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
assign5JS.js, in which you will add your code.
assign5.htmlin 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:
amountto be broken into bills, and
bill denominationto use in breaking the amount.
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)
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
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.
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.
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.
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.
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.