In this tutorial, we are going to learn how to find the area of a triangle.

A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry. A triangle with vertices A, B, and C is denoted △ABC.

We can calculate the area of a triangle based on the below given formula.

Area of Triangle=(width * height) / 2;

Let's see how to write a Java program and use this formula.

Program 1 : Find the area of a triangle in Java

Output

Width of Triangle: 21.75 Height of Triangle: 10.5 Area of Triangle: 114.1875

Program 2 : Find the area of a triangle in Java with user input

Output

Enter Triangle width: 30.5 Enter Triangle Height: 20.75 Area of Triangle: 316.4375

That's all guys, hope this Java Program is helpful for you.

Happy Learning... 😀

Please share this article on social media to help others.

If you have any query or suggestion regarding this artical please share with us feedback@javabytechie.com