From 7f7ccbfbecf0b276bfcc8892e3f478d8a3ce1297 Mon Sep 17 00:00:00 2001 From: "@kylash" <145746053+kylashreddy@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:22:24 +0530 Subject: [PATCH] Create area of heagon2.java --- area of heagon2.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 area of heagon2.java diff --git a/area of heagon2.java b/area of heagon2.java new file mode 100644 index 0000000..54c6526 --- /dev/null +++ b/area of heagon2.java @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class HexagonAreaCalculator { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the length of one side of the hexagon: "); + double sideLength = scanner.nextDouble(); + + double area = calculateHexagonArea(sideLength); + System.out.println("The area of the hexagon is: " + area); + + scanner.close(); + } + + public static double calculateHexagonArea(double sideLength) { + // Calculate the area using the formula + double area = (3 * Math.sqrt(3) * Math.pow(sideLength, 2)) / 2; + return area; + } +}