For some reason when I run the program (I get no errors when compiling) I get o's for my awnsers no matter what radius is used. I think its probably something stupid thing I overlooked, and i need a wiser person than I to help me out!
Circle class then demo
Edit: and never, EVER name your object reference the same as the class name. It's confusing and against most Java best practices.
Nick Harms wrote:So I could say circle shape and switch the bottom parts to shape.getcircumference for example? that's ok?
That would be preferable.
it looks like getRadius is/could be a static method.
The goal should be to make code more readable and less confusing..... not just so it "just works".
Nick Harms wrote: It will first ask the user for their radius and then send that to the class to be used in the methods to find the information.
Well maybe you should program it to do that....
Katrina tells me frequently of someone who named their variables a, then aa, then aaa, then aaaa..... et cetera. The computer doesn't care. It will work. But how will you change/fix/debug it?
Being able to pick good reference/variable names is important.
Nick Harms wrote:I thought that was what the object did? Do i simply need to move the object to after I ask them instead of before.
What happens if you try?
You could also do a more lazy instantiation and declare rad in the same line as setting it equal to nextDouble.
And while we're on the subject of naming things.... you might change rad to 'radius' . Letters are free and it adds to readability.
Thanks again, you are my hero. I knew it was something stupid!
Another AH HA! moment thanks to java ranch.