import java.io.*;
public class slope extends Object
{
public static void main(String[] args)
{
try
{
BufferedReader myReader =
new BufferedReader(new InputStreamReader(System.in));
// Prompt the user for x and y coordinates for the
// first point and read them in.
System.out.println( "Enter x coordinate of the first point : ");
string input = myReader.readLine();
double x1 = Double.parseDouble( input );
System.out.println( "Enter y coordinate of the first point : ");
string input = myReader.readLine();
double y1 = Double.parseDouble( input );
// Prompt the user for x and y coordinate for the
// second point and read them in.
System.out.println( "Enter x coordinate of the second point : ");
string input = myReader.readLine();
double x2 = Double.parseDouble( input );
System.out.println( "Enter y coordinate of the second point : ");
string input = myReader.readLine();
double y2 = Double.parseDouble( input );
double lineSlope = (x2 - x1) / (y2 - y1);
System.out.println( "The slope of the line is " + lineSlope);
}
catch(Exception e)
{
System.out.println("bad input");
System.exit(1);
}
// End main
}
}
2006-09-05
15:43:57
·
3 answers
·
asked by
mark79_24
1
in
Computers & Internet
➔ Programming & Design