Solved

help for some formulas

Posted on 2003-11-20
4
529 Views
Last Modified: 2010-04-01
Hello friends,
I recently bought your book "C How to Program" Introducing C++ and Java 3rd Edition.

I was solving the exercises in all the chapters. But iam stuck with the following question. Certainly iam not a student and this is not my assignment. Moreover i don't need the program,just the formula.

==================================
Write an inheritance hierarchy for class Quadrilateral, Trapezoid, SymmetricTrapezoid,
Parallelogram, Rectangle, and Square. Use Quadrilateral as the base class of the
hierarchy. Make the hierarchy as deep (i.e., as many levels) as possible. The private data of
Quadrilateral should be (x, y) coordinate pairs for the four endpoints of the Quadrilateral.
Supply virtual functions double area(), double periphery(), point middle() (an
intersection of diagonals).
Write a driver program that instantiates and displays objects of each of these classes and tests all the
functions. Test at least 2 objects of each class. As you create each Quadrilateral, place a
Quadrilateral* pointer to each new Quadrilateral object into an array.

==================================

I have 2 doubts. Please clarify them.

1. What is known as periphery? Does it mean perimeter? If it doesn't then please give the formula for calculating it for all the shapes.

2. Can you please give me the formula for calculating the area, periphery and middle for the
   Trapezoid and Symmetric Trapezoid. I remember the formulas for other shapes.

I thank in advance for your help.

With kind regards,
Neo.
0
Comment
Question by:NeoParker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
bcladd earned 50 total points
ID: 9791166
(1) I assume periphery is perimeter.

(2) Area of a trapazoid with height h and bottom base length b1 and top base length b2 (bases are the parallel sides: (b1 + b2)/2 * h; it doesn't matter whether or not it is symetric: the central rectangle yeilds b2*h for the area and the remaining tail ends can be combined into a triangle with height h and base b1-b2 and the area of that is (b1 - b2) * h / 2 so total area is

h * (b2 + (b1 - b2)/2) = h * (b2 + b1/2 - b2/2) = h * (b1 + b2)/2

-bcl
0
 
LVL 3

Expert Comment

by:monkesdb
ID: 9791480
as bcladd says the area is h*(b1 + b2)/2

and the perimiter is the sum of the length of all the sides but if your only given h, b1 and b2 you can't determine it. you need another peice of information, something like the seperation of the top and bottom.

  s
<-->_____b2_________
    /|                              \
  /  | h                              \
 /__|____________________\
<------------------------------->
                   b1

then you can do it. it's

b1 + b2 + sqrt( s^2 + h^2 ) + sqrt( (b1 - s - b2)^2 + h^2 )

For the symetrical trapezoid the center is easy. assume that (0, 0) is the left end of b1 then the center is at

(b1 / 2, h * b2 / b1)

but for the none symetrical you need to know s

( (s + (b2 + b1) / 2) / 2, h * b2 / b1 )


(i think)

0
 
LVL 9

Expert Comment

by:_ys_
ID: 9797507
Periphery is not necessarily perimeter:
On a 2D object it is perimeter.
On a 3D object it's the entire surface.

In the context of your question however, treat is as perimeter - as all objects are 2D.
0
 
LVL 3

Expert Comment

by:monkesdb
ID: 9804246
bcladd gave you area

i gave you the other perimiter and center

the points should be split up fairly

(unless you contest my answer)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question