Menu Bar

Horizontal Scrollable Menu

Search This Blog

What is a polygon? | Java Area of Triangle

What is a polygon?

A polygon is any 2-dimensional shape formed with straight lines. Triangles, quadrilateral, pentagon and hexagon are all examples of polygons.

A regular polygon is a polygon in which all sides of the polygon are of equal length.
We have a mathematical formula so that the area of ​​a regular polygon can be calculated.
Area = (ln * ln * n / 4 * (tan (180 / n))
Where
ln = Length of edge of polygon
Number of sides in a polygon =
tan = touch function in degrees

Area of Triangle in Java

import java.io.*;
import java.util.*;
class Area
{
public static void main(String []args)
{
Scanner ob=new Scanner(System.in);
int l,h;
l=ob.nextInt();
h=ob.nextInt();
System.out.println("enter value l and h");
double t=0.5*l*h;
System.out.println("Area of Triangle:"+t);
}
}

No comments:

ads3