#Math code not giving expected answer

11 messages · Page 1 of 1 (latest)

grand topaz
#

The surface area is correct, however the volume is not. The formula is correct so I cannot figure out why it's not working as expected.

zenith topazBOT
#

This post has been reserved for your question.

Hey @grand topaz! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

gentle vortex
#

4/3 = 1

#

that's integer division

#

do 4/3d or 4d/3 or 4d/3d or 4/3.0 etc etc

grand topaz
#

ah ok i completely forgot about that

gentle vortex
#

since you're storing stuff in doubles, use nextDouble instead of nextFloat to get more accuracy

#

also consider using printf to get the precision you need

grand topaz
#

Alright

#

thanks for the help