Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

A) Specifications

In this assignment, you will implement the mathematical object - a regular hexagon - as an abstract data type (i.e. as a class). A regular hexagon is a polygon with six edges of equal length - organized in a way that all the interior angles are equal. One can think of it as six equilateral triangles put together. Since all the properties about a hexagon are completely determined given just the length of the side, the class should need only one private member - the side. You will need to implement the following public functions for the class: 
1) void setSide(double) - initialize the side of the hexagon
2) double getSide() - return the side of the hexagon
3) double getDiagonal() - return the length of the diagonal of the hexagon (diagonal = 2 * side ?)
4) double getPerimeter() - return the length of the perimeter of the hexagon (perimeter = 6 * side ?)
5) double getArea() - return the area of the hexagon. The area of a hexagon is given by the following formula: Area = (3 * square_root(3) / 2) * side2
6) double AreaOfOuterCircle() - return the area of the "outer" circle that circumscribes the regular hexagon.
7) double AreaOfInnerCircle() - return the area of the "inner" circle circumscribed by the regular hexagon.

You also need to implement a constructor for the class. The constructor should take a parameter which is used to initialize the side of the hexagon. In the constructor, print out the message "We are creating a hexagon with side = ", and print out the side of the hexagon. The side is given as a parameter to the constructor. 

In the main function, you will need to implement the necessary pieces of code that "try out" the test cases. Before a particular test is performed, you should always print a message prompting the user of the test that you are about to perform.

B) Testing

There are totally two tests you should perform in the program. In each test, you should use the member functions of the class to print out all the data about the hexagon (i.e. side, diagonal, perimeter, and its area). You should also print a message that says "The data of the hexagon are as follows:" before you generate all the hexagon data on the screen. 

Test One: Create a hexagon object via the constructor using the initial side value of 4.0. After the object is created, print all the data about it on the screen (don't forget to print the prompting message first).

Test Two: This time, you ask the user for the side and initialize the hexagon with user input using the appropriate member function. Then, just output all the data about the hexagon on the screen like what you did in test one.

C) Bonus
1) Students who use a loop in the main function when asking for the user for input - so that the user can repeatedly test the program with different inputs until the user enter "Q" as an input - will receive a decent amount of bonus points. Points will only be given, however, if screenshots are provided.

2) Input validation - students who check if user's inputs are valid (e.g. length > 0?) will receive a decent amount of bonus points.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9121001

Have any Question?


Related Questions in Computer Engineering

Question suppose you are given two circularly linked lists

Question : Suppose you are given two circularly linked lists, L and M. Create an algorithm for telling if L and M store the same sequence of elements (but perhaps with different starting points). It needs to have a main ...

A restaurant offers a 12 dinner special that has 7 choices

A restaurant offers a? $12 dinner special that has 7 choices for an? appetizer, 13 choices for an? entrée, and 4 choices for a dessert. How many different meals are available when you select an? appetizer, an? entrée, an ...

A orange juice producer buys all of his oranges from a

A orange juice producer buys all of his oranges from a large orange orchard in Florida. Suppose that the amount of juice squeezed form each of these oranges is normally distributed with a mean of 4.70 and a standard devi ...

Recall that s-des operates on a block size of 8 bits

Recall that S-DES operates on a block size of 8 bits, producing a ciphertext that is also 8 bits long. a. In this scenario, how many different ciphertexts are there? b. How many different 8-bit block ciphers can there be ...

How does understanding various microsoft office

How does understanding various Microsoft Office applications enhance productivity in education, the workplace, and at home?

Identify economic decision that is driven by a behavioral

Identify economic decision that is driven by a behavioral bias rather than by pure rational behavior. why are they differ today?

In a competitive market the market demand is qd 60- 6p and

In a competitive market, the market demand is Qd= 60- 6P and the market supply is the Qs= 4P the full economic price under a price ceiling of $3 is:?

Question suppose you need to store 10 tb of data in a new

Question Suppose you need to store 10 TB of data in a new data center. How many 2 GB hard disks do you need if the hard disk should store up to 70% of their capacity using RAID 0, RAID 1, RAID 3, or RAID 5.

Remote direct memory access rdma enables efficient memory

Remote Direct Memory Access (RDMA) enables efficient memory access from one computer to another. Read about it using Google Scholar, ACM Digital Library or any professional literature tools. Write a 150-200 words (refere ...

Need a use case diagram for a case studythe case studypaul

Need a use case diagram for a case study: The case study Paul is the Director of IT Services for a consulting firm Avant. The firm has been growing fast since it was launched in 2010. With over 100 employees and hundreds ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As