In geometry, a hexagon is also a type of polygon with 6 sides. If the hexagon is regular, then the lengths of all the sides will be the same as well as all the angles will be equal. Clearly, the sides of a regular hexagon are congruent. To find out the area of a hexagon, it is first divided into small six isosceles triangles as shown in Figure 1. Then, the area of one of the triangles is calculated and then multiply by 6 to find the total area of the hexagon. 120° 60 Figure 1: Hexagon The area of a hexagon can be calculated using the following formula, 3/3 Area = x a² 2 and the perimeter using the formula, P = 6 × a hexagon. • Based on the given formulas write a class called Hexagon that contains o necessary data member(s) where a is the length of one side of the necessary member functions to get input from the user, manipulate the data member(s), and output the result of the perimeter, P and area, Area of the hexagon (2 decimal points). Display the results to the screen as well as a data file named 'hexa.txt'. o constructor to initialize some or all the data member(s) • Write a main function that tests your class by asking the user to input 6 values the length of one side, a, and test the constructor. Following is the example of the output screen and the data file “hexa.txt". Screen from constructor: length Perimeter hexa.txt Area hexa - Notepad 2.00 12.00 10.39 File Edit Format View Help 2.00 12.00 10.39 2.00 12.00 10.39 length Perimeter Area 2.00 12.00 10.39
In geometry, a hexagon is also a type of polygon with 6 sides. If the hexagon is regular, then the lengths of all the sides will be the same as well as all the angles will be equal. Clearly, the sides of a regular hexagon are congruent. To find out the area of a hexagon, it is first divided into small six isosceles triangles as shown in Figure 1. Then, the area of one of the triangles is calculated and then multiply by 6 to find the total area of the hexagon. 120° 60 Figure 1: Hexagon The area of a hexagon can be calculated using the following formula, 3/3 Area = x a² 2 and the perimeter using the formula, P = 6 × a hexagon. • Based on the given formulas write a class called Hexagon that contains o necessary data member(s) where a is the length of one side of the necessary member functions to get input from the user, manipulate the data member(s), and output the result of the perimeter, P and area, Area of the hexagon (2 decimal points). Display the results to the screen as well as a data file named 'hexa.txt'. o constructor to initialize some or all the data member(s) • Write a main function that tests your class by asking the user to input 6 values the length of one side, a, and test the constructor. Following is the example of the output screen and the data file “hexa.txt". Screen from constructor: length Perimeter hexa.txt Area hexa - Notepad 2.00 12.00 10.39 File Edit Format View Help 2.00 12.00 10.39 2.00 12.00 10.39 length Perimeter Area 2.00 12.00 10.39
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
C++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education