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