I am doing the 4.5 exercises which has to do with the area of regular pentagon.
(Geometry: area of a regular polygon) A regular polygon is an n-sided polygon in
which all sides are of the same length and all angles have the same degree (i.e., the
polygon is both equilateral and equiangular). The formula for computing the area
of a regular polygon is :
I have checked errata on their page and they did not list the type-o under the final result.
Errata link (http://www.cs.armstrong.edu/liang/intro10e/errata.html)
their result is
Enter the number of sides: 5
Enter the side: 6.5
The area of the polygon is 74.69017017488385
and mine is Area of regular pentagon is 72.69017017488385
is it a code error?
Thanks for assistance
You cannot get an int out of the pow method which returns a double.
And no change for 1234567890
Actually, there are several ways. One uses only primitive types, and is very fast.
But yes, I was referring to converting the ints to longs, yes. They have more precision than double, and are big enough to handle the square of any int, exactly.
I agree with Campbell: it is a lose-lose situation.
First: Mike is right to point out that Campbells quote was a tad on the, eh, very firm
side. But Mike was triggered by the word 'always', and Campbell did not use that word.
But let's hope that OP got the answer he was hoping for.