Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Assignment 1 -Intro to programming javascript

Start

// DECLARE VARIABLES AND CONSTANTS
DECLARE numberOfMiles AS number
DECLARE numberOfKm AS number
DECLARE CONSTANT BR=”
” //HTML line break tag

// GET INPUT FROM USER
DISPLAY “Enter number in kilometers to convert it to miles:”
INPUT numberOfKm
DISPLAY “Enter number in miles to convert it to kilometers:”
INPUT numberOfMiles

// PROCESSING CALCULATE Number Of kilometers AND Number Of Miles
numberOfKm = 1.609 * numberOfMiles // to transfer number of Mile to Kilometers
numberOfMiles = 0.6214 * numberOfKm //to transfer number of Kilometers to Miles

// OUTPUT
DISPLAY “miles is Equivalent to Kilometers” + numberOfKm
DISPLAY “Kilometers is Equivalent to miles” + numberOfMiles

//Close program

<html>
<body>
<script type="text/javascript">

// Variable Declarations
var BR = "<br />";
var numberOfMiles;
var numberOfKm;

// input 1
numberOfMiles = prompt("Enter number in miles to convert it to kilometers:", "");
// PROCESSING 1
numberOfKm = 1.609 * numberOfMiles;
// OUPUT 1
document.write(numberOfMiles + " " + " miles is Equivalent to" + " " 
+ numberOfKm.toFixed(6) + " " + " Kilometers " + BR);

// input 2
numberOfKm = prompt("Enter number in kilometers to convert it to miles ", "");
// PROCESSING 2
numberOfMiles = 0.6214 * numberOfKm;
// OUPUT 2
document.write(numberOfKm + " " + "Kilometers is Equivalent to" +" " 
+ numberOfMiles.toFixed(6) + " miles " + BR);

</script>
</body>
</html>



About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!