CS381 – Coursework I

advertisement
CS381 Individual Assignment - Jan 2004
CS381 Web Technologies
Individual Assignment I – Jan 2004 (20 Marks)
Deadline : Monday 16th February 2004 at 12:00
The assignment should be handed in as a printed report together with the electronic
version of the code (i.e. in a floppy, or CD-ROM) to the undergraduate office before
the deadline.
Exercises:
A. Java Applet and JavaScript interaction.
Create a Java Applet that adds two given numbers and displays the results.
a. First create an HTML file with all the necessary elements.
b. Create the Java Applet. The Applet should contain at least one function that
takes two parameters (the two numbers to be added) and then it prints out the
sum of the two numbers.
c. Insert the Applet to the HTML file.
d. Add two text elements on the page where the user will insert the two numbers.
e. Add a button element on the page so that when the user clicks on it, the two
numbers are passed (using JavaScript) to the Applet.
f. The Applet should display the sum of the two numbers.
B. JavaScript form validation.
Create JavaScript functions that will validate a form containing details about the
user’s full name, email address, telephone number, and postcode.
a. First create an HTML file with all the necessary elements.
b. Add four text elements: one for the full name, one for the email, one for the
telephone number, and one for the postcode.
c. Add one button that when pressed it will validate the details entered in the text
fields.
d. The validation should include at least the following:
i. No empty fields are allowed, or fields with white spaces only.
ii. Full name should only contain letters.
iii. Telephone number should only have numerical values, space
between the numbers is allowed, and it should at least have 10
digits.
iv. Email address should comply with international standards.
Page 1 of 3
CS381 Individual Assignment - Jan 2004
v. Postcode should comply with the UK standards.
e. When the user makes a wrong entry, a message should appear describing the
problem. The message should at least point out which field is invalid.
C. Message encryption.
Using JavaScript, write a mechanism for encrypting / decrypting messages. The
user should be able to define the encryption key and encrypt a message. Then the
user should be able to decrypt the message and get back the original text based on
the same encryption key.
a. First create an HTML file with all the necessary elements.
b. Add two text elements: one for entering the sequence of characters that you
want to encrypt and one for entering the sequence of characters to be
encrypted into.
e.g.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
All upper case letters
…
WXYZABCDEFGHIJKLMNOPQRSTUV
Encryption
So, the word “HELLO” becomes “DAHHK”.
c. Add two text areas: one for entering the message to be encrypted and one for
the encrypted message.
d. Add a button that, when clicked, it will encrypt the message based on the
encryption key and then display the encrypted message.
e. Add one more text area and one button, so that when the button is pressed it
will decrypt the encrypted message back to the original message and then
display it.
f. Try to encrypt the message:
“Hello there, this is the ENCRYPTED message with ID=2004!”
g. Decrypt the message back. The original and the decrypted message should be
the same.
Page 2 of 3
CS381 Individual Assignment - Jan 2004
HINTS:
1. Don’t forget to add a form element on the HTML page.
2. Name all elements you are going to use, giving them a unique name.
3. Keep the code simple and use comments where necessary.
Formatting : Your report should be written in Courier New (or similar) font size 10
(or 12). All margins should be set to at least 1/2 inch.
WARNING : You are free to use any books or electronic resources for your report.
However the report should be written in your own words. Copying programming
code, sentences, paragraphs, sections word by word or diagrams and pictures from
documents that belong to other people including your classmates is called plagiarism.
Every document deemed to contain copied material will incur severe penalties in
marking. It can be given a total mark of 0. To avoid this you must reference all
your sources and write the ideas you found in other documents in your own words. If
in doubt as to what constitutes plagiarism please come and see me immediately.
Marking scheme :
Exercise A.
Exercise B.
Exercise C.
6 Marks
7 Marks
7 Marks
Bogdan Vrusias
B.Vrusias@surrey.ac.uk
Page 3 of 3
Download