-
-
Save mariiaKolokolova/bc1009579501936cb730179a8faf9e90 to your computer and use it in GitHub Desktop.
Lesson1_Area_of_triangle
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 maricka.kolokolova; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
Scanner sc = new Scanner(System.in); | |
double a; | |
double b; | |
double c; | |
System.out.println("Input a:"); | |
a = sc.nextDouble(); | |
System.out.println("Input b:"); | |
b = sc.nextDouble(); | |
System.out.println("Input c:"); | |
c = sc.nextDouble(); | |
double p = (a + b + c) / 2; | |
double sq = Math.sqrt(p * (p - a) * (p - b) * (p - c)); | |
System.out.println("Area of a triangle: " + sq); | |
sc.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment