Saturday, 23 April 2016

Calculates The Distance Between Two Points (x1, y1) And (x2, y2). All Numbers And Return Values Should Be Floating-Point Values

Write function distance that calculates the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be floating-point values. Incorporate this function into a script that enables the user to enter the coordinates of the points through an HTML form.Bottom of Form

Copy Code From Here

distence.html


<html>
<head><title>Pro5</title>
<script>
function find_distance()
{
var x1=parseInt(document.getElementById("x1").value);
var y1=parseInt(document.getElementById("y1").value);
var x2=parseInt(document.getElementById("x2").value);
var y2=parseInt(document.getElementById("y2").value);
var distance=Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2));
alert("Distance: "+distance);
}
</script>
</head>
<body>
<form name="f1" method="post">
<label>Enter the co-ordinate of point p:</label><br>
x1:<input type="text" id="x1" size="30"/>&nbsp;y1:<input type="text" id="y1" size="30"/><br>
<label>Enter the co-ordinate of point q:</label><br>
x2:<input type="text" id="x2" size="30"/>&nbsp;y2:<input type="text" id="y2" size="30"/><br>
<button onclick="find_distance()">Find Distance</button>
</form>
</body>
</html

Output:-

www.programmingwithbasics.com

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment