Index
 Syllabus
 Announcements
 Schedule
 Assignments
 Exams
 Resources

Assignment 5

Due: Wednesday, May 26

JavaScript Expressions and Functions

  1. Create a Web page or Web pages similar to  mathtest.html that tests the following Javascript Math functions Math.max, Math.floor, and Math.random. You can start with the example file mathtest.html and modify it as necessary. It may be easier to create separate pages for each function (e.g., mathtest-max.html, mathtest-floor.html, etc.). In each case, the user should be prompted to enter the value for the operands of the operation, and the output should be written onto the page in teh same style as the example program in mathtest.html . Note that the Math.random() function does not have any input parameters, once it is invoked it simply produces a random number between 0 and 1.
  2. Create a Web page named grades.html that can be used to compute a student's overall average for a course. Your page should prompt the user to enter his or her homework average, lab average, midterm score, and final exam score. The page should store each value as a number in a separate variable and then use the four numbers to to compute and display the course average. Assume the following grade weightings: Homework (25%), Labs (20%), Midterm (25%), and Final (30%). The class average is computed as the weighted average of these four elements:

                   average = homework*0.25 + labs*0.20 + midterm*0.25 + final*0.30

    Your final display on the page should show the scores inputted for each item followed by the overall class average (something like this Figure).
  3. Modify the convert.js library from class by adding two metric conversion functions: a function m2k  to convert a distance from miles to kilometers and a function p2k to convert a given weight in pounds to kilograms. Then create a Web page metric-convert.html that prompts the user twice (once to enter a distance in miles and once to enter a weight  in pounds) and writes out the equivalent values in metric units. Be sure that your Web page displays both the inputs provided by the user and the outputs computed by the program (you can use the convert2.html program discussed in class as a model).

What to Submit

Before uploading the files to the server, test your page on your local computer to make sure everything works and looks as intended. On your student Web space (inside the  public_html folder), navigate to the it130 Folder and create a new subfolder called hw5. Using SSH upload the pages you have created and any associated files (including your convert.js file from problem 3) to this folder on the server, set their permissions for the files and folders, and check them with your browser.  You should create your Web pages using a text editor such as TextPad or similar program on your local computer before uploading it. The link to submit should look something line the following:

http://students.depaul.edu/~yourlogin/it130/hw5/

Important: set the permission for the folder hw5 so that it is readable by all users (public). This will allow the contents of the folder (your pages for the above exercises) to be listed as links. Test the URL in your browser to make sure that all of the pages and other files you have created for the assignment are visible and accessible.

Submit this URLvia Course Online (type the URL into the comment box).

Please see the syllabus for the policy on late assignments.


Back to Assignments