Assignment 0 - Finding Syntax Errors

You hand in this assignment by showing it to the lecturer when it is completed. This assignment contains some syntax errors you should correct and it works well when you can run it without an error message been displayed and the 10 randomly chosen numbers analyzed correctly.
  1. Getting Started.
    Log on your UNIX account.
    Create the directory "public_html" to have a webpage and go into it.
            mkdir public_html
            chmod 711 ~/
            chmod 755 public_html
            cd public_html 
    Download this page onto your computer and place it on your webpage.
            wget http://www.comp.nus.edu.sg/~gem1501/assignment00.html
            chmod 755 *.html 
    The wget command copies a file into your page.
    In the case that you have messed up your file completely,
    you can do the following commands to get it back.
            rm assignment00.html
            wget http://www.comp.nus.edu.sg/~gem1501/assignment00.html
            chmod 755 *.html 
    The "chmod" command makes everything on your webpage publically readable.
    So you can look with your browser at your page.
    Use an editor like pico and vi to look at the file.

  2. Make yourself familiar with the program.
    Most of a webpage is written in Hypertext Markup Language (HTML).
    But this page contains also some parts in Java Script.
    Note that there is an other programming language with
    the name Java, but Java Script shares with it just the name.
    These parts are mixed into the html-page.
    In order to make it easier for you to learn to program
    with Java Script, you receive almost ready programs.
    So you do not need to learn html.

    Follow the link for an introduction to Java Script.

  3. Task of this exercise.
    This exercise is quite easy. Its main task is to teach you to find typing errors in a program, this process is called debugging. The given program has errors in seven lines and you should find and correct them all; some of the faulty statements are superfluous and can be deleted, others have to be corrected.

    The browser Internet Explorer helps finding the bugs. To do this you have to change the default settings.
    1. Go to the menu "Tools" and then to the last row "Internet Options".
    2. A new window "Internet Options pops up. Go to the entry "Advanced" in the list of subwindows on the top.
    3. Check the box "Display a notification about every script error" (sixth box under the entry "Browsing").
    4. Press "OK" in the lowest row to finish.
    Having done this, you should on one hand edit the file with the text of this page and on the other hand press the "refresh" or "reloading" button of the browser to see the effect of what you are doing.
    Note that you should view the details of the announced Java Script errors to get the line numbers.

  4. What the correct program does.
    The corrected program computes for 10 randomly chosen numbers between 1 and 99 the divisors and checks whether the number is prime, square or having only one decimal digit. The number and the diagnosis about it are printed out.

Java Script Starts Here.


Java Script Ends Here.