11-29-2009, 08:00 PM
Code:
import java.util.*;
class slope
{
public static void main(String[] args)
{
int x = 1;
while (x == 1)
{
Scanner x1s = new Scanner(System.in);
Scanner x2s = new Scanner(System.in);
Scanner y1s = new Scanner(System.in);
Scanner y2s = new Scanner(System.in);
float x1;
float x2;
float y1;
float y2;
System.out.print("First x: ");
x1 = x1s.nextInt();
System.out.print("First y: ");
y1 = y1s.nextInt();
System.out.print("Second x: ");
x2 = x2s.nextInt();
System.out.print("Second y: ");
y2 = y2s.nextInt();
float y2y1 = y2 - y1;
float x2x1 = x2 - x1;
System.out.println(y2y1/x2x1);
}
}
}