Java program to find area of triangle

Let’s learn java program to find area of triangle.

Java program to find area of triangle

In the below area of triangle program in java user enters base-width and height of triangle using nextDouble() method of Scanner class.

To calculate area of triangle in java formula is:

Area = (width * height) / 2

Here’s the java program to calculate area of triangle.

import java.util.Scanner;
public class FindAreaOfTriangle
   public static void main(String[] args)
      Scanner sc = new Scanner(;
      System.out.println("Please enter width of triangle: ");
      double base = sc.nextDouble();
      System.out.println("Please enter height of triangle: ");
      double height = sc.nextDouble();
      // formula area of triangle = (width * height) / 2
      double area = (base * height) / 2;
      System.out.println("Area of triangle is: " + area);


Please enter width of triangle: 5
Please enter height of triangle: 5
Area of triangle is: 12.5

Also read – major features of java