Are your dimensions those shown as r1, r2 and h below?
.\ /|\
. |
. \ |
. |
. \ |
. |
. \ |
. |
- ---------- | APEX
/|\ | r1 \ |
| | \ |
| | \ |
h | \ |
| | \ |
| | \ |
\|/ | r2 \ \|/
- ------------------ -
|
If so, you may find it easier to find the hypothetical apex height of the original cone first:
APEX = h * r2 / (r2 - r1)
Then the height of the removed cone with radius r1, is APEX - h.
Volume and curved surface area best found by subtraction as WHOLE CONE minus REMOVED CONE.
Volume (for a non-truncated cone) = PI.R
2.H/3
Curved surface area (for a non-truncated cone) = PI.R.L, where L is slant length.
Slant length L found by Pythagoras. For the total surface area you presumably wish to add the circular areas at top and bottom.
After a lot of algebra, and some fortuitous(?) cancellation, I get
V = PI (r
12+r
22+r
1r
2)h/3
A = PI [ (r
1+r
2)S + r
12 + r
22 ] (including top and bottom circles)
where
S = sqrt[ h
2 + (r
2-r
1)
2 ]
is the slant length of the truncated cone.
I would always write
R * R
, not
pow(R,2)
.
Your BRACKETING is wrong. If you space out your variables much more, you will find it easier to get brackets in the correct place - this is particularly true of your sqrt() calculation for slant height and the collection of terms for volume.
You might also like to make PI a little more accurate, whilst "Interger" is actually spelt "double".