Let’s learn area of octagon in java.

## Area of Octagon in java

An octagon is a geometrical figure which has eight sides of same length and internal angles of same size. To calculate area of octagon formula is

Area of octagon: 2 × (side length)² × (1 + sqrt(2))

Now let’s see java program.

import java.util.Scanner; public class AreaOfOctagon { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Please enter length of side of octagon: "); int side = sc.nextInt(); float area = (float) (2 * (1 + Math.sqrt(2)) * side * side); System.out.println("Area of octagon is: " + area); sc.close(); } }

**Output:**

Please enter length of side of octagon:

5

Area of octagon is: 120.71068

Also read – major features of java