Assignment 7: Basic JavaScript due: start of class, 7/13 Read Snyder Chapter 18 Do: Lab 4.1 10 Points Total Name_____________________ Lab 4.1 Exercises 4. Open the web page you just saved to run the JavaScript program. What happens when you open the file? Make sure to describe what is displayed in the browser window. Looking at the web page source (e.g., in your Notepad window), what tags are around the part of the HTML that is actually displayed in the browser window? What tags are around the part of the HTML that forms your JavaScript program? Where, if anywhere, is the text inside the head tags displayed? 5. Reload the page in the browser window. What, if anything, happens when you reload the page? 7. Reload your browser window. Which message shows up in the dialog box that pops up: the old one or your new one? 8. Describe what happens when you reload the web page. 9. What is the problem with the line above? after inserting bug in step 9… 10. Reload the page in your browser. Describe what happens. after recofiguring your browser… 12. Try reloading the browser again. This time, you should get some error message. What line does the browser say the error is on? 13. Correct the bug and reload the page. Describe what happens now. 14. “Break” the opening <script> tag by removing the < character. Doesreloading the page result in an error message? What is displayed on the web page? 15. Undo the last change and remove the close-parenthesis in the second alert line. What, if any error message, results when the page is reloaded? Part 4 Write the CurrencyConverter program described in notes. Get an exchange rate from www.xe.com/ict (click on Currency Table, then Click here to generate Currency Table). Use the Units per USD number. If take dollars*rate you get the amount in the new currency. Code that into your program. When it works. Print out the SOURCE from Notepad and staple it to this sheet. PostLab Questions 1. A programming language is designed to be a human-readable (and -writeable!) way to tell computers what to do. Programming languages allow us to give computers instructions. Most computer scientists would agree that JavaScript is a programming language, but many would not consider HTML one. Discuss one similarity between JavaScript and HTML that suggests both might be programming languages. Discuss one difference between JavaScript and HTML that suggests only JavaScript is a programming language. (over ) 2. Consider the concepts of input and output in the context of everyday devices. The telephone takes input via its dialing buttons (or dial, if you have a rotary phone) and the end of the handset you speak into. Phone output comes from the ringer and the end of the handset you listen to. Consider each the following everyday devices and describe their input and output as thoroughly as possible: television— portable CD player— 3. Consider the short JavaScript program you work with in Parts 2 and 3 of this lab. Does this program have input, output, both? Describe the input and/or output. How about the currency converter program? Does this program have input, output, or both? Chapter 18 Exercises: Multiple choice: 1___ 2___ 3___ 4___ 5___ 6___ 7___ 8___ 9___ 10___ 11___ 12___ Short Answer: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10 11. 12. 13. 14. 15. Exercises: 1. Name Math operator Relational operator less than ____ ____ less than or equal to ____ ____ greater than ____ ____ greater than or equal to ____ ____ equal to ____ ____ not equal to ____ ____ 2. var price; var taxRate = 0.087; if(drink == “espresso”) price = 1.00; if(drink == “latte” || drink == “cappuccino”){ if(ounce == 8) price = 1.55; if(ounce == 12) price = 1.95; if(ounce == 16) price = 2.35; } if(drink == “Americano”) price = 1.10 + .30 * (ounce/8); price = price + (shots – 1) * .70; price = price + price * taxRate; 7. wont_work = “five” * 5 + “5” – ‘5’ 3 * 7 = wont_work wont_work == a / b “wont_work” = m * n