<< Chapter < Page Chapter >> Page >

Compute, save, and apply the conversion factor f3

Following that, a conversion factor named f3 is computed that can be used to convert a value expressed in feet to the same value expressed in miles. Thisconversion factor is based on the known fact that there are 5280 feet in a mile.

The factor named f3 is applied to the distance that is now expressed in feet converting it to a new value that expresses the same distance in miles (1mile).

Analysis of the units

The comment that reads

//feet*mile/feet = mile

is an analysis that shows the units that will result from applying the conversion factor to the distance at this point. As you can see, the feet termswill cancel and the result will be in miles.

That satisfies the specifications

That satisfies the original program specification. However, I mentioned earlier that if a conversion factor X can be used to convert from A-units toB-units, the reciprocal of X can be used to convert from B-units back to A-units.

Reversing the process

Continuing with Listing 1 , the comment that reads

//(pace/inch)*(inch/foot)*(foot/mile) = pace/mile

shows the units that survive from a product of the reciprocals of f1 , f2 , and f3 . As you can see, after canceling out inches and feet, the result of multiplying the reciprocals of those three conversion factors is a new conversionfactor that can be used to convert a value expressed in miles to a new value that represents the same distance expressed in paces.

That conversion factor is applied to the distance in miles producing an output of 2112, which unsurprisingly, is the distance in paces that we startedoff with.

More substantive JavaScript examples

Assume that you drop a rock from a balloon at a height of 10000 feet above the ground, Further assume that the positive direction is up and the negativedirection is down.

What would be the height of the rock above the ground at the end of ten seconds? What would be the height of the rock at the end of twenty seconds?

An equation relating distance, acceleration, and time

As you will learn in a future module, the following equation gives the distance that the rock will travel as a function of time assuming that the initial velocity is zero . (The assumption is that the rock was simply dropped and not thrown .)

d = 0.5 * g * t^2

where

  • d is the distance traveled
  • g is the acceleration of gravity (approximately -32.2 ft/s^2)
  • t is time is seconds

Free fall exercise

Please copy the code from Listing 2 into an html file and open it in your browser.

Listing 2 . Free fall exercise.
>!-- File JavaScript02.html --<>html<>body<>script language="JavaScript1.3"<//Function to compute free-fall distance for a given time // in seconds.function distance(time){ var g = -32.174; //acceleration of gravity in feet/sec^2var d = 0.5 * g * time * time;//(feet/sec^2)*sec^2 = feet return new Number(d.toFixed(0));}//end function //Compute and display height at ten seconds.var t1 = 10;//time in seconds var d1 = distance(t1);//distance traveled in feetvar h1 = 10000 + d1;//height in feet document.write("At " + t1 + " seconds:" +">/br<"); document.write("distance traveled = " + d1 +" feet>/br<") document.write("height = " + h1 +" feet>/br<") //Compute and display height at twenty seconds.var t2 = 20;//time in seconds var d2 = distance(t2);//distance traveled in feetvar h2 = 10000 + d2;//height in feet document.write(">/br<At " + t2 + " seconds:" +">/br<"); document.write("distance traveled = " + d2 +" feet>/br<") document.write("height = " + h2 +" feet>/br<") document.write(">/br<The End")>/script<>/body<>/html<

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Accessible physics concepts for blind students. OpenStax CNX. Oct 02, 2015 Download for free at https://legacy.cnx.org/content/col11294/1.36
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Accessible physics concepts for blind students' conversation and receive update notifications?

Ask