Advertisement
yashirokira

Untitled

May 3rd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package exercicio2;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11.  *
  12.  * @author Kira1
  13.  */
  14. public class Exercicio2 {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.     public static void main(String[] args) {
  20.    
  21.         float x1,x2,x3,y1,y2,y3;
  22.         float d1,d2,d3;
  23.         Scanner teclado = new Scanner(System.in);
  24.        
  25.         System.out.print("Digite o primeiro valor para x ");
  26.         x1 = teclado.nextInt();
  27.         System.out.print("Digite o primeiro valor para y ");
  28.         y1 = teclado.nextInt();
  29.         System.out.print("Digite o segundo valor para x ");
  30.         x2 = teclado.nextInt();
  31.         System.out.print("Digite o segundo valor para y ");
  32.         y2 = teclado.nextInt();
  33.         System.out.print("Digite o terceiro valor para x ");
  34.         x3 = teclado.nextInt();
  35.         System.out.print("Digite o terceiro valor para y ");
  36.         y3 = teclado.nextInt();
  37.        
  38.         d1 = (float)Math.sqrt((x1 - x2)*(x1 - x2)+((y1 - y2)*(y1 - y2)));
  39.         System.out.println("Distancia 1 " + d1);
  40.        
  41.         d2 = (float)Math.sqrt((x2 - x3)*(x2 - x3)+((y2 - y3)*(y2 - y3)));
  42.         System.out.println("Distancia 2 " + d2);
  43.        
  44.         d3 = (float)Math.sqrt((x1 - x3)*(x1 - x3)+((y1 - y3)*(y1 - y3)));
  45.         System.out.println("Distancia 3 " + d3);
  46.        
  47.         if ( Math.abs(d2-d3)<d1 & d1<(d2+d3) & Math.abs(d1-d3)<d2 & d2<(d1+d3) & Math.abs(d1-d2)<d3 & d3<(d2+d1)){                  
  48.                     if ( d1 == d3 & d2 == d1)
  49.                         System.out.println("Este é um triângulo equilátero.");                      
  50.                     else if ( d1 == d3 || d2 == d1 || d3 == d2)
  51.                         System.out.println("Este triângulo é isósceles.");                  
  52.                     else
  53.                         System.out.println("Este triângulo é escaleno.");
  54.         }
  55.            else
  56.                System.out.println("Coordenadas não se referem à um triângulo.");
  57. }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement