IT130 Final Exam with Answers November 11, 2008 1. (10 pts) Explain, so someone that is not an expert at computers, the interrelationship between HTML, CSS and JavaScript. Ans: HTML means Hypertext Markup Language. In addition to specifying the text on a webpage, it specifies the appearence of the text like whether it is in bold or italic, where the paragraph breaks are and what the headers on the page look like. HTML also specifies where the images, hyperlinks to other pages and special controls like textboxes, buttons, dropdown menus are placed. CSS means cascading style sheets. It controls the style of page, for example, what fonts are used in which locations, the sizes of the fonts, the page color and text colors. It also controls details like indentation and table borders and margins. It can also be used for special effects like overlaying text on images. JavaScript is a computer language for specifying dynamic effects, that is items on the page that change in response to user input or input from other sources. Some of these effects might be calculations based in user input, image slide shows, or real-time date clocks. 2. (5 pts) How do write a source code comment in HTML source code, CSS, and JavaScript. Ans: HTML: CSS: /* This is a comment. */ JavaScript: // This is a comment. 3. (5 pts) Give the rgb color codes for these colors: Green Ans: rgb(255,0,0) Yellow Ans: rgb(255,255,0) Maroon Ans: rgb(128,0,0) Light Gray (You choose the lightness of gray.) Ans: rgb(128,128,128) 4. (15 pts) Write a CSS document-level style to do the following: a. Set the font for the body to Papyrus. b. Set the background color of the body to AliceBlue. c. Set the text color of the body to Navy. d. Set the font size of all size 2 headings to 1.5 times normal size. e. Set the size of all images to 100 by 100 pixels. f. Set the font of all input controls to Verdana. Ans: body { font-family: Papyrus; background-color: AliceBlue; color: Navy; } h2 { font-size: 150%; } img { width: 100px; height: 100px; } input { font-family: Verdana; } 5. (2 pts) Write a JavaScript statement that declares the variables a, b and c. Ans: var a, b, c; 6. (5 pts) Write a JavaScript statement that obtains a value from the textbox txtInput, converts it to a number and assigns it to the variable a. Assume that the form name is frmMain. Ans: a = parseFloat(document.frmMain.txtInput.value); 7. (5 pts) Write a JavaScript statement takes the value in the variable b and assigns it to the textbox txtOutput. Assume that the form name is frmMain. Ans: document.frmMain.txtOutput.value = b; 8. (5 pts) Write a line of JavaScript code that displays the message File not found. Ans: alert(File not found.); 9. (5 pts) Write a line of JavaScript that displays usa.gif in the image control with name imgFlag. Ans: document.images.imgFlag.src = usa.gif; 10. (5 pts) Write HTML code that defines a dropdown menu that displays the items MasterCard and Visa. Ans: 11. (5 pts) Write a link tag for an external style that accesses style.css in the parent folder. Ans: 12. (5 pts) Write a JavaScript expression that randomly displays one of the integers 1, 2, 3, 4, 5 with equal probability. Ans: document.write(1 + Math.floor(5 * Math.random( ))); 13. Find as many mistakes as you can in the following code. Make corrections directly on the code; do not recopy. The number of British Pounds in a Euro is 0.81861. 16 <-- Interchange lines 16 and 17 17 <-- Insert
18

19 Pounds <-- In line 19, replace txtEuro with txtPounds 20

22

23 <-- In line 24, replace Convert; with convert( ); 25

<-- replace

with

<-- Insert

26 Euro <-- In line 26, replace textbox with text <-- In line 26, replace txteuro with txtEuro <-- In line 26, replace txtEuro with txtEuro <-- In line 26, replace > with /> 27

<-- Insert
28 <-- Replace with 29 <-- Replace with