Hallo,
habe hier mal ein kleines Programm gebastelt.
Es ließt Zwei Punkte (X,Y) ein und berechnet dann den Abstand der beiden Punkte.
JAVA Programming /**
* v1.1 vom 30.09.2008
* Philipp S.
*/
import java.io.*;
public class PunktAbstand
{
public static void main(String args[])throws IOException
{
BufferedReader input= new BufferedReader(new InputStreamReader(System.in));
double y1=0,
y2=0,
x1=0,
x2=0,
a=0,
b=0,
c=0;
System.out.println("Punktabstand");
System.out.print("1.Punkt x:");
x1=Double.parseDouble(input.readLine());
System.out.print("1.Punkt y:");
y1=Double.parseDouble(input.readLine());
System.out.print("2.Punkt x:");
x2=Double.parseDouble(input.readLine());
System.out.print("2.Punkt y:");
y2=Double.parseDouble(input.readLine());
//Rechnung
a=x2 - x1;
b=y2 - y1;
c=Math.sqrt((a * a) + (b * b));
System.out.println("Der Punktabstand: "+c);
System.out.println("Programmende PunktAbstand.");
}
} Habe nur die PHP-Code Box genommen das es dort korrekt eingerückt is.
Gruß,
Toasterfraktion