Java program to find the area of an **Isosceles triangle** or to calculate the area of an isosceles triangle. Before we discuss the programming code what is an isosceles triangle ? And what are the main functions of an isosceles?

**#Below is the online execution & compile tool for the following code check it out #**

**What is an isosceles triangle ?**

An isosceles triangle is a triangle where any two sides of a triangle should be equal both in terms of length and angles. Below is the sample figure.

**What is the formula to find out the area of an isosceles triangle ?**

Since the area of a normal triangle and isosceles have the same formula. And, the same program is applicable when it comes to the coding part in java. Here goes the formula , make sure to note down the base and height values. The base is opposite to the two-sided lengths or angles which are in equal.

**[ B/4√((4*a*a)-(b*b)) ]**

**You can write the code in different formats ,one of the format here as follows , consider it has # sample method -1**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import java.util.Scanner; class AreaOfIsoscelesTriangle { public static void main(String args[]) { Scanner s= new Scanner(System.in); System.out.println("Enter the length of same sided"); double a= s.nextDouble(); System.out.println("Enter the side2 of the Triangle"); double b= s.nextDouble(); double area=(b/4)*Math.sqrt((4*a*a)-(b*b)); System.out.println("Area of Isosceles Triangle is: " + area); } } |

**Output:**

1 2 3 4 5 |
Enter the length of same sided 5 Enter the side2 of the Triangle 8 Area of Isosceles Triangle is:12.0 |

**As normal , we can calculate the area of an isosceles triangle with the standard formula , in order to make the unique one. we write the java program in a different method. check it out the above code so that you will get an idea.**

There may be so many different ways in order to calculate the are area of an isosceles , here the math formula that we are used as ” **[ B/4√((4*a*a)-(b*b)) ]** “.

**Here goes the complete explanation of the above code :**

**1)** No need to say about the ” **import java.util.Scanner;** ” you may have an idea bout that.

**2)**

1 |
Class AreaOfIsoscelesTriangle |

– Allocating a particular name for the following code.

**3)**

1 |
public static void main(String args[]) |

– The code start executing from here.

**4)**

1 |
Scanner s= new Scanner(System.in); |

– The scanner is a class , which is inbuilt in JDK package which can read the inputs from the system , whereas system.in is to read the inputs from the same system that you were using.

**5)**

1 |
System.out.println("Enter the length of same sided"); |

– instruction for user to Enter the value of side of triangle .the value is same for two sides.

**6)**

1 |
double a= s.nextDouble(); |

it take first input and stores value in variable a.

**7)**

1 |
double b= s.nextDouble(); |

Same as follows for the : side 3

**8)**

1 |
double area=(b/4)*Math.sqrt((4*a*a)-(b*b)); |

– java formula to find the area of an isosceles

**9)**

1 |
System.out.println("Area of Triangle is: " + area); |

-Output displayed on the screen , once you were start compiling and executing the values.

So, that’s the complete explanation of how the java program code works in order to find the area of an isosceles triangle. If you have any doubt related to this section do comment here , we are glad to help you out.

**Moreover , here is the #sample method-2 , you can even compile and execute the program here !**

In the above code , we are not using the scanner function , where scanner function is an inbuilt package that read the inputs from the system , in this case, scanner function is not available on online compiler , for that purpose we are using the command line arguments methodoly to get input from the user to do this correctly we need some function parseXXX() method to will convert string to number format.

**Note : **While you were using the arguments to read the input values , enter the values from ” **1-10 space 1-10** “. The first value is the length of the two same sides , and next one is a side of the another length.

You can also use the** “Int” instead of ” Double”** , where double can represent the values even after decimal points to , whereas in Int will won’t display the values.

If you have any doubts related to this section do comment here, we are glad to help you out related to this query.

**# Java program to find the area of an isosceles triangle end # **