Skip to content

Instantly share code, notes, and snippets.

@Sergaav
Created March 25, 2015 14:36
Show Gist options
  • Save Sergaav/7fe10b616607b0b72bde to your computer and use it in GitHub Desktop.
Save Sergaav/7fe10b616607b0b72bde to your computer and use it in GitHub Desktop.
square of trianle
package com.gmail.sergaav.dz1_2;
import java.util.Scanner;
public class dz1_2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Введите стороны треугольника :\n" + "Сторона а:");
double a = sc.nextDouble();
System.out.println("\n" + "Сторона b:");
double b = sc.nextDouble();
System.out.println("\n" + "Сторона c:");
double c = sc.nextDouble();
if ((a < b + c) && (b < a + c) && (c < a + b)) {
double p;
p = (a + b + c) / 2;
double s;
s = Math.sqrt(p * (p - a) * (p - b) * (p - c));
System.out.println("Площадь треугольника= " + s);
} else
System.out.println("Неверно заданы стороны треугольника");
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment