/* Name: Richard Fox Class: CSC 260.002 Date: 8/17/16 */ import java.util.*; public class RightTriangle1 { public static void main(String[] args) { int p1x, p1y, p2x, p2y, p3x, p3y; double s1, s2, s3; boolean right; Scanner in=new Scanner(System.in); System.out.print("Input p1x: "); p1x=in.nextInt(); System.out.print("Input p1y: "); p1y=in.nextInt(); System.out.print("Input p2x: "); p2x=in.nextInt(); System.out.print("Input p2y: "); p2y=in.nextInt(); System.out.print("Input p3x: "); p3x=in.nextInt(); System.out.print("Input p3y: "); p3y=in.nextInt(); s1=computeSide(p1x,p1y,p2x,p2y); s2=computeSide(p2x,p2y,p3x,p3y); s3=computeSide(p3x,p3y,p1x,p1y); right=computePythagorean(s1,s2,s3); if(right) System.out.println("the triangle formed out of these points is a right triangle"); else System.out.println("the triangle formed out of these points is a not right triangle"); System.exit(0); } public static double computeSide(int x1, int y1, int x2, int y2) { return Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2)); } public static boolean computePythagorean(double s1, double s2, double s3) { if(s1>s2&&s1>s3) return (s1==Math.sqrt(s2*s2+s3*s3)); else if (s2>s1&&s2>s3) return (s2==Math.sqrt(s1*s1+s3*s3)); else return (s3==Math.sqrt(s1*s1+s2*s2)); } }