Answers for "area of scalene triangle in java"

0

area of scalene triangle in java

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // area of scalene triangle 

        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter the sides (a,b,c): ");
        float side1 = scanner.nextFloat(), side2 = scanner.nextFloat(), side3 = scanner.nextFloat();

        float semiPerimeter = (side1 + side2 + side3) / 2;

        double area = Math.sqrt( semiPerimeter * (semiPerimeter-side1) * (semiPerimeter-side2) * (semiPerimeter-side3) );

        System.out.printf("The area is %.2f",area);
    }
}
Posted by: Guest on June-27-2021

Code answers related to "area of scalene triangle in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language