Skip to content

Instantly share code, notes, and snippets.

@mariiaKolokolova
Created April 26, 2020 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariiaKolokolova/bc1009579501936cb730179a8faf9e90 to your computer and use it in GitHub Desktop.
Save mariiaKolokolova/bc1009579501936cb730179a8faf9e90 to your computer and use it in GitHub Desktop.
Lesson1_Area_of_triangle
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