Java Program To Calculate Area Of Triangle
Chapter:
Miscellaneous
Last Updated:
13-08-2016 13:18:44 UTC
Program:
/* ............... START ............... */
import java.util.Scanner;
public class JavaAreaOfTriangle {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the width of the Triangle:");
double base = scanner.nextDouble();
System.out.println("Enter the height of the Triangle:");
double height = scanner.nextDouble();
double area = (base * height) / 2;
System.out.println("Area of Triangle is: " + area);
}
}
/* ............... END ............... */
Output
Enter the width of the Triangle:
20
Enter the height of the Triangle:
30
Area of Triangle is: 300.0
Notes:
-
A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry.
Tags
Calculate Area Of Triangle, Java