Docsity

Autumn 2011/12 Interactive Web Dev Exam - Q1: DNI Validation, Exams of Computer Science

Toggle sidebar
bg1
Page 1 of 8
CORK INSTITUTE OF TECHNOLOGY
INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ
Autumn Examinations 2011/12
Module Title: Interactive Web Development (CA)
Module Code:
SOFT6008
School:
Science & Informatics
Programme Title(s):
Higher Certificate in Computing – Year 2
BSc in Computing – Year 2
BSc (Hons) in Software Development & Computer Networking – Year 2
Programme Code(s):
KCOME_6_Y2 / KCOMP_7_Y2 / KDNET_8_Y2
External Examiner(s):
Mr Aidan Quilligan
Internal Examiner(s):
Colin Manning
Instructions:
Answer all 3 questions for full marks.
Duration:
2 hours
Sitting:
Autumn 2012
Requirements for this examination:
Note to Candidates: Please check the Programme Title and the Module Title to ensure that you have received the
correct examination. If in doubt please contact an Invigilator.
pf3
pf4
pf5
pf8

Partial preview of the text

Download Autumn 2011/12 Interactive Web Dev Exam - Q1: DNI Validation and more Exams Computer Science in PDF only on Docsity!

CORK INSTITUTE OF TECHNOLOGY

INSTITIÚID TEICNEOLAÍOCHTA CHORCAÍ

Autumn Examinations 2011/

Module Title: Interactive Web Development (CA)

Module Code: SOFT

School: Science & Informatics

Programme Title(s):

Higher Certificate in Computing – Year 2 BSc in Computing – Year 2 BSc (Hons) in Software Development & Computer Networking – Year 2

Programme Code(s): KCOME_6_Y2 / KCOMP_7_Y2 / KDNET_8_Y

External Examiner(s): Mr Aidan Quilligan

Internal Examiner(s): Colin Manning

Instructions: Answer all 3 questions for full marks.

Duration: 2 hours

Sitting: Autumn 2012

Requirements for this examination:

Note to Candidates: Please check the Programme Title and the Module Title to ensure that you have received the correct examination. If in doubt please contact an Invigilator.

Question 1 (45 marks) The webpage and javascript code shown is for a page that accepts a Spanish DNI number in an input box. When the check button is pressed javascript code checks the format of the number and the check letter.

If the format and check letter are correct the code •modifies the “graphic” image using the DOM so that is displays “thumbs-up.png” •changes the background colour of the element with ID “outputtext” to green

  • and provides text feedback using the same element (shown)

If the format or check letter are incorrect the code •modifies the “graphic” image using the DOM so that is displays “thumbs-down.png” •changes the background colour of the element with ID “outputtext” to red

  • and provides text feedback using the same element

Q1. (a-e) In the code shown some of the javascript has been removed. Write the missing code. (40 marks)

The DNI number is 8 digits followed by a letter, possibly separated by “-” (e.g 12345678T, 12345678-t). To calculate the check letter the numeric part is taken to be an integer. The mod 23 of that integer gives a number that indicates the correct check letter. The mapping of number to letters is detailed in the table below.

Mod 23 Letter Mod 23 Letter Mod 23 Letter

0 T 8 P 16 Q

1 R 9 D 17 V

2 W 10 X 18 H

3 A 11 B 19 L

4 G 12 N 20 C

5 M 13 J 21 K

6 Y 14 Z 22 E

7 F 15 S

Q1. (f) (5 marks) Only 23 letters are required for this check letter scheme. But the first 23 letters of the alphabet were not chosen. Explain the choice of letters.

// get mod 23

dnimod = dninum % 23;

// map mod to letter. Letter should be uppercase by now madstring ="TRWAGMYFPDXBNJZSQVHLCKE";

(d)

// do the input letter and the calculated letter match?

if (!(dniletter == dniletter2)) valid=false;

return valid; }

function checknumber() {

var num = ""; num = document.forms["DNIform"]["DNInumber"].value if (goodDNI(num)) {

document.getElementById("outputtext").innerHTML= num + " looks good to me!"; (e)

This page checks a DNI number to ensure that:

it contains 8 digits followed by 1 letter (possibly with - separator) the check letter is correct

Enter the DNI to see if it is correct

Phone number:

Right now I know nothing

Check

[Don’t forget to answer Q1. Part (f) ]

Question 3 (30 marks)

Mr. SpudHead is a child’s game that allows a player to change the nose, eyes, and mouth of a cartoon potato. A potato image shares the same space on a web page with an image for each of a nose, eyes, mouth. However because portions of the images are transparent, they can all be seen. When overlaid in this fashion they make up the face of Mr. SpudHead.

A button labelled “nose” cycles through each of the available noses when clicked. Similar buttons for ears, eyes, and mouth cycle though the other parts of the face. Combined together they allow any combination of the parts to be displayed.

There are 5 nose images named nose0.png, nose1.png, nose2.png, nose3.png, nose4.png. Similarly there are 5 images each for eyes and mouths..

The HTML fragment below shows the IDs if the elements and the code on the buttons. The CSS ensures that the images all occupy the same space.

Write the JavaScript code for the doeyes() function.

eyes nose mouth