Last Updated:

How to calculate area of a triangle using Java

In this article, we will look at a small program for calculating the area of a triangle in Java. This article is part of a section for novice Java programmers.

The triangle area counting program in Java interacts with the user and displays the results of the calculations on the console. Using the Scanner class, the program calculates the values of the height and width of the triangle entered by the user and then uses the methods of the System class to publish the results of the calculations to the console:

The result of the Java triangle area calculation program: