Answers for "area of isosceles triangle in java"

0

area of isosceles triangle in java

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // area of isosceles triangle

        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter length of same side: ");
        float equalLength = scanner.nextFloat();

        System.out.print("Enter length of the other side: ");
        float base = scanner.nextFloat();

        float height = (float) Math.sqrt(Math.pow(equalLength,2) - (base / 4) );

        double area = 0.5f * base * height;

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

area of isosceles triangle in java

import java.util.Scanner;
public class AreaOfIsoscelesTriangle
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter length of same sided: ");
      double a = sc.nextDouble();
      System.out.println("Please enter side2 of isosceles triangle: ");
      double b = sc.nextDouble();
      double area = (b/4) * Math.sqrt((4 * a * a) - (b * b));
      System.out.println("Area of isosceles triangle is: " + area);
      sc.close();
   }
}
Posted by: Guest on October-30-2020

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

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language