InLab07 - In-Lab Assignment #7: JavaScript Instructions:...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: In-Lab Assignment #7: JavaScript Instructions: Select any problems for a maximum of 10 points (no extra credit). Collaboration is permitted. Students present during lab have until midnight tomorrow to submit their files. Submit your .html files as instructed by your TA. Introduction: JavaScript is widely used in web pages when an algorithm of some kind is needed. This is because HTML does not have certain important programming features such as loops. You will write a JavaScript "program" to see the similarities to Java and gain a broader perspective on programming languages. Be sure to complete the corresponding tutorial on JavaScript if you are not familiar with this language. Standard Set 1. (4 pts) Create a web page with a JavaScript program that declares and initializes the following variables and displays the result of dividing the first by the second. Division works the same as in Java by using the "/" operator. Note that JavaScript does not truncate fractional parts of a number when doing integer division. Value Variable x 1 y 2 Output x divided by y equals 0.5 2. (6 pts) Using JavaScript, display the first one-hundred powers of 2 using a loop, but without using any math methods such as pow(). Hint: use a "for" loop that multiplies a variable by 2 in each iteration. The following is what your output would look like for the first ten values: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ... To keep things simple, you can have an extra comma at the end. Note that you need to display 100 values. When the values become extremely large, they will be displayed using the scientific notation xe+y which means x 10 y . For example, the last two values of your output should be approximately 3.16 1029 and 6.33 1029 and should appear as follows: 3.1691265005705736e+29, 6.338253001141147e+29, ...
View Full Document

This note was uploaded on 04/10/2008 for the course ENGR 131 taught by Professor Xiaowei during the Spring '07 term at Case Western.

Ask a homework question - tutors are online