Below is some very simple code for finding the diameter, circumference, and area of a circle with a radius inputed by the user. Can someone please tell me why it is not running?
Thanks!
[ October 17, 2006: Message edited by: Chris Reech ]
[ October 17, 2006: Message edited by: Chris Reech ] [ October 17, 2006: Message edited by: Chris Reech ]
Originally posted by Chetan Parekh: Chris Reech, Add try/catch block in your code - as I mentioned before.
Check how to do that below
[ October 18, 2006: Message edited by: Chetan Parekh ]
Excellent, it worked! 2 more things:
I am very novice so please bear with me. How do you assign the radius to a float variable? Also, I need to drop .0 from the diameter value and shorten the decimal places to 3. Shown below.
Or use System.out.printf(...) instead of System.out.println(...) to print the output. With printf, you can specify the format that you want for the numbers. Look it up in the API documentation (you can find printf(...) in the class java.io.PrintStream).
Example:
Post by:autobot
catch it before it slithers away! Oh wait, it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking