Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package exercicio2;
- import java.util.Scanner;
- /**
- *
- * @author Kira1
- */
- public class Exercicio2 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- float x1,x2,x3,y1,y2,y3;
- float d1,d2,d3;
- Scanner teclado = new Scanner(System.in);
- System.out.print("Digite o primeiro valor para x ");
- x1 = teclado.nextInt();
- System.out.print("Digite o primeiro valor para y ");
- y1 = teclado.nextInt();
- System.out.print("Digite o segundo valor para x ");
- x2 = teclado.nextInt();
- System.out.print("Digite o segundo valor para y ");
- y2 = teclado.nextInt();
- System.out.print("Digite o terceiro valor para x ");
- x3 = teclado.nextInt();
- System.out.print("Digite o terceiro valor para y ");
- y3 = teclado.nextInt();
- d1 = (float)Math.sqrt((x1 - x2)*(x1 - x2)+((y1 - y2)*(y1 - y2)));
- System.out.println("Distancia 1 " + d1);
- d2 = (float)Math.sqrt((x2 - x3)*(x2 - x3)+((y2 - y3)*(y2 - y3)));
- System.out.println("Distancia 2 " + d2);
- d3 = (float)Math.sqrt((x1 - x3)*(x1 - x3)+((y1 - y3)*(y1 - y3)));
- System.out.println("Distancia 3 " + d3);
- 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)){
- if ( d1 == d3 & d2 == d1)
- System.out.println("Este é um triângulo equilátero.");
- else if ( d1 == d3 || d2 == d1 || d3 == d2)
- System.out.println("Este triângulo é isósceles.");
- else
- System.out.println("Este triângulo é escaleno.");
- }
- else
- System.out.println("Coordenadas não se referem à um triângulo.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement