Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package Snajdr;
- import java.util.*;
- import static java.lang.Math.*;
- /**
- *
- * @author snajpa
- */
- public class Snajdr {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- double[] lengths = {0, 0, 0};
- double[][] coords = {{0,0}, {0,0}, {0,0}};
- System.out.print("Give me a point A (syntax: <number_x> <number_y>: ");
- coords[0][0] = sc.nextDouble();
- coords[0][1] = sc.nextDouble();
- System.out.print("Give me a point B (syntax: <number_x> <number_y>: ");
- coords[1][0] = sc.nextDouble();
- coords[1][1] = sc.nextDouble();
- System.out.print("Give me a point C (syntax: <number_x> <number_y>: ");
- coords[2][0] = sc.nextDouble();
- coords[2][1] = sc.nextDouble();
- lengths[0] = sqrt(pow(coords[0][0]-coords[1][0], 2) +
- pow(coords[0][1]-coords[1][1], 2));
- lengths[1] = sqrt(pow(coords[1][0]-coords[2][0], 2) +
- pow(coords[1][1]-coords[2][1], 2));
- lengths[2] = sqrt(pow(coords[2][0]-coords[0][0], 2) +
- pow(coords[2][1]-coords[0][1], 2));
- Arrays.sort(lengths);
- System.out.println("Triangle properties:");
- if ((lengths[0] + lengths[1]) == lengths[2]) {
- System.out.println("-> Degenerated");
- } else {
- if (sqrt(pow(lengths[0],2) + pow(lengths[1],2)) == lengths[2]) {
- System.out.println("-> Right");
- }
- if ((lengths[0] == lengths[1]) && (lengths[1] == lengths[2]) &&
- (lengths[0] == lengths[2])) {
- System.out.println("-> Equilateral");
- } else if ((lengths[0] == lengths[1]) || (lengths[1] == lengths[2]) ||
- (lengths[0] == lengths[2])) {
- System.out.println("-> Isosceles");
- }
- }
- System.out.println("Lengths ascending:");
- System.out.println(lengths[0]);
- System.out.println(lengths[1]);
- System.out.println(lengths[2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement