Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My third program: Slope Finder
#1
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);
        }
    }    
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)