How this blog work !
" I create this web blog for helping all computer science students and who interested in computer science. That means this blog work as a helper in your educational carrier. If you have any doubts in your subject (computer science) and you want to know more about in your syllabus topics or Seminar topics pleas E-mail your doubts and your name ,college name, Email ID to edugang@gmail.com . Then you will get the answer with in week (I ensure 99% chance to get your answer) in your email address.If you forgot to send your name ,college name ,Email ID then I can’t publish your answer.If you want the answer of any question immediately (with in a day)you can contact me in my number shown in the about "

Wednesday, October 13, 2010

program to find the distance between two points

Buzz It
Question :program to find the distance between two points
 
Question From :
 Fathima Neethu
Malappuram 
fathimaneethu88@gmail.com
Answer:
 import java.io.*;
import java.lang.*;
import java.lang.Math;
import java.io.DataInputStream;
class Distance
{
    int x1,x2,y1,y2;
    void calculate()
    {
       
    try
    {
        DataInputStream in=new DataInputStream(System.in);
        System.out.println("Enter the coordinates : ");
        x1=Integer.parseInt(in.readLine());
        y1=Integer.parseInt(in.readLine());
        System.out.println("Enter the coordinates : ");
        x2=Integer.parseInt(in.readLine());
        y2=Integer.parseInt(in.readLine());
        System.out.println("Distance between the points : ");
        System.out.println(Math.sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1))));
}
catch(Exception e)
{
}

    }
}
class DistanceDemo
{
public static void main(String args[])
{
    Distance distance=new Distance();
    distance.calculate();
    }
}

O/P

 

0 comments:

Post a Comment

 

CSedukit.com | Headlines

Sponsors

Advertise Now!