Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

Information about an examination held at cork institute of technology in autumn 2011/12 for the interactive web development module (soft6008). The examination consisted of three questions, and this json focuses on the first question. The question required candidates to complete the javascript code for validating a spanish dni number, which consists of eight digits followed by a letter. The code includes functions for checking the format and length of the number, extracting the numeric part and the letter, calculating the check letter using the modulo 23 method, and comparing the calculated letter with the input letter.

Typology: Exams

2012/2013

Uploaded on 03/24/2013

anandi
anandi 🇮🇳

4.5

(8)

72 documents

1 / 8

Toggle sidebar

Related documents


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! 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. Page 2 of 8 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. Page 5 of 8 <body> <div> This page checks a DNI number to ensure that: <ul> <li>it contains 8 digits followed by 1 letter (possibly with - separator)</li> <li>the check letter is correct</li> </ul> <br/><br/><br/><br/> Enter the DNI to see if it is correct <br/><br/> <img src="question-mark.png" name="graphic" width="300" height="300" alt="Graphical Feedback" /> <br/><br/> <form name="DNIform"> Phone number: <input type="text" name="DNInumber" /><br /> </form> </div> <div id="outputtext" style="background-color:#999999; width:400"> Right now I know nothing</div> <br/><br/> <button type="button" onclick="checknumber()">Check</button> </html> [Don’t forget to answer Q1. Part (f) ] Page 6 of 8 Question 2 The following code fragment reads a phone number from a cookie. intLocation = strCookie.indexOf("phone="); intStart = intLocation + 6; intEnd = strCookie.indexOf(";", intStart); if (intEnd==-1) intEnd=document.cookie.length; strPh = strCookie.substring(intStart, intEnd); (f) (10 marks) What is the purpose of the code fragment in bold? (g) (15 marks) Write a generic cookie reading function called readMyCookie. It should take a single string parameter and evaluate to the value associated with the cookie of that name. e.g. readMyCookie (“phone”) might evaluate to “0871234567” If there is no cookie with the same name as the passed parameter, it should evaluate to -1. Page 7 of 8 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..
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved