Created
March 25, 2015 14:36
-
-
Save Sergaav/7fe10b616607b0b72bde to your computer and use it in GitHub Desktop.
square of trianle
This file contains 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.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