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

## Java program to find area of triangle

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

Also read – inheritance in java

To calculate area of triangle formula is:

Area = (width * height) / 2

Here’s the java program.

import java.util.Scanner; public class FindAreaOfTriangle { public static void main(String[] args) { Scanner sc = new Scanner(System.in); 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); sc.close(); } }

**Output:**

Please enter width of triangle: 5

Please enter height of triangle: 5

Area of triangle is: 12.5

Never stop learning. Learn java programming and how to code java.