Write a program that prompts the user to enter the side of a hexagon and displays its area.
Solution:
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
double side, area;
System.out.print("Enter the side:");
side = s.nextDouble();
area = (6 * Math.pow(side, 2)) / (4 * Math.tan(Math.toRadians(30)));
System.out.printf("The area of the hexagon is %4.2f.", area);
}
Very nice post.Thanks for sharing your knowledge to us.This is very helpfull programming post.
ReplyDeleteAdvantages Of DBMS Over File Management System