print
Advertisment
Advertisment

Area of Octagon

Example 2

import java.util.Scanner;
class Raj{

 public static void main(String[] args) {
 
  int side;
  float area;
  System.out.print("\nEnter the length of the side :");
    Scanner sc = new Scanner(System.in);

   side = sc.nextInt();
   area = (float)(2*(1+Math.sqrt(2)) * side * side);

    System.out.println("\nArea of regular octagon :"+area);

     }
   }

Output :

 
   
  Enter the length of side: 3
  Area of regular octagon: 43.4558
   
Advertisment
Advertisment
arrow_upward