Sunteți pe pagina 1din 3

Practice Exam #1

1. Within an electrical circuit what does a transistor do?


a. store electricity
b. allow electricity to flow in only one direction
c. act like an automated switch
d. resist the flow of electricity

2. What does the CPU in a computer do?


a. perform calculations
b. transfer data
c. convert alternating current to direct current
d. temporarily store data

3. What does main memory in a computer do?


a. perform calculations
b. transfer data
c. convert alternating current to direct current
d. temporarily store data

4. How do you write a comment in HTML?

5. What meta tag do we normally use in our HTML?

6. Write the tag and closing tag that surround an entire HTML document.

7. What is the tag that ends the body of an HTML document?

8. Write the HTML for a button to invoke the function findAnswer.

10. What is the id attribute used for?

11. What does the JavaScript function parseFloat do?

14. What value does the variable thing have after:


var animal = 5;
var thing = "This " + animal;

15. What value will result have?


var a = 3, b = 6, c = -7;
var result = a - b * 5 + c;

16. Translate the following expression into JavaScript

17. Rewrite the following statement so it uses the *= operator


scale = scale * growth;
18. Rewrite the following JavaScript statement without using the auto-increment operator:
++g;

19. Write a defining table for a program that calculates an employee's after-tax pay. Inputs include the
employee's regular hours worked, overtime hours worked, and regular hourly wage. Overtime hours
are paid at one and a half times the regular hourly wage. The employee's income is taxed at 18%. Your
output is the after-tax pay.

20. Write a JavaScript program to solve the problem from #19. You may use the following HTML code
if you wish:

<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Employee After-Tax Pay</title>
<script>

// Your function here

</script>
</head>

<body>
<h1>How much will this employee earn?</h1>
Regular Hours <input type="text" id="regularHours"><br>
Overtime Hours <input type="text" id="overtimeHours"><br>
Regular Hourly Wage <input type="text" id="hourlyWage"><br>
Employee's After-Tax Pay <div id="output"></div>
</body>
</html>
21. Write a defining table for a program that finds the length of the third side of a triangle using the law
of cosines. Input includes the length of two of the sides of the triangle (side1, side2) and the angle
between side1 and side2 (alpha). Your output is the length of the third side of the triangle. The law of
cosines is:
side 32 =side 12 +side 22 2side 1side 2cos ( alpha )

22. Write a JavaScript program to solve the problem from #21. You may wish to use the function
Math.cos . You may use the following HTML code if you wish:

<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Area of a triangle</title>
<script>

// Your function here

</script>
</head>

<body>
<h1>What is the length of the third side of a triangle?</h1>
Length of Side 1 <input type="text" id="side1"><br>
Length of Side 2 <input type="text" id="side2"><br>
Angle between sides <input type="text" id="alpha"><br>
Length of the third side of the triangle <div id="area"></div>
</body>
</html>

S-ar putea să vă placă și