Find Area Of Triangle in Java

You are currently viewing Find Area Of Triangle in Java

In this article, You are going to learn the concept of find area of triangle in java program. Firstly, We will talk about the area of a triangle and how to find an area of triangle using java program? Let’s see the possibilities here.

What is an area of triangle?

The area of a triangle is defined as the total space occupied by the three sides of a triangle in a 2-dimensional plane.

This is a formula for calculating an area of a triangle that will be given below:

Area = ( Base * Height ) / 2

Find Area Of Triangle in Java

We can find the area of triangle in java using the below program.

public class test  
 {  
   public static void main (String args[])  
    {          float b=4,h =16,area ;  
                         area = ( b*h) / 2 ;  
                         System.out.println("Area of Triangle is: "+area);  
    }}  

How to Execute a Program?

Initially, We have to assign the two respective variables which will use to store the input values of base and height. After executing this program, The area of the triangle will be calculated by using the formula. Finally, The system.out.printIn() function will show the result on the output screen.

Read Also : Armstrong Number in Java

Note

If you want to Find Area of Triangle in JavaScript then please read the article which I have already posted on our website.

Output

The output of the find area of triangle in java will be given below for your reference.

Area of Triangle is: 32.0

Final Words

I hope this article helps you to Find the Area of the Triangle using the Java Program. If you face any issues please let me know via the comment section. Share this article with other Java program developers via social networks. Thank You!

Manoj S

Hi, I'm Manoj working as a part-time blogger in Coding Diksha. Here, I post about programming to help developers.

Leave a Reply