Created
February 15, 2020 21:52
-
-
Save Khuzha/06db272c2cad3f12037e653a1ee869b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.khuzha.objects; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
Scanner scan = new Scanner(System.in); | |
System.out.println("Введите длину стороны а:"); | |
float a = scan.nextInt(); | |
System.out.println("Введите длину стороны b:"); | |
float b = scan.nextInt(); | |
System.out.println("Введите длину стороны с:"); | |
float c = scan.nextInt(); | |
if (a + b < c || a + c < b || b + c < a) { | |
System.out.println("Такого треугольника не существует."); | |
return; | |
} | |
float p = (float) (0.5 * (a + b + c)); | |
float s = (float) (p * (p - a) * (p - b) * (p - c)); | |
float h = (float) (2 * Math.sqrt(s) / a); | |
System.out.println("Высоты, опущенная на сторону а, равна " + h); | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment