Javascript Assignment
Javascript Assignment
Use the document.write commands to display the output for each of the following JavaScript
programs (Note: Format your output).
1. Write a program that computes the duration of a projectiles flight and its height above
ground when it reaches the target using the formula given.
<body>
<script>
var g = 9.8
var e = 20
var v = 245
var d = 3.5
var t, h
d = d * 1000 //convert km to m
t = d / (v * Math.cos(e))
t = t.toFixed(2) //fixed into 2 decimal places
<body>
Point 1: (3,7)<br>
Point 2: (8,12)<br>
<br>
<script>
var x1 = 3, y1 = 7, x2 = 8, y2 = 12
var slope, mx, my, mid, distance
slope = (y2-y1)/(x2-x1)
mx = (x1+x2)/2
my = (y1+y2)/2
distance = Math.sqrt(Math.pow(x1-x2,2) + Math.pow(y1-y2,2))