The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

How do I expand this code? I have no idea what my teacher wants.

Hello! In my beginning Java class, our teacher gave us the assignment to ask the user for the radius of a circle and then to output the area and circumference based on their input. Well I wrote this code, thinking it was what he wanted, but he gives me feedback saying "No, expand it more." But we've only gone over what's in the code below. We haven't gone over 'if...else if' or anything else more advanced than what's below, so any ideas on what he wants? Because I have looked at it and don't know how he wants me to expand it or put more code in there. Thanks in advance!

Re: How do I expand this code? I have no idea what my teacher wants.

Things that might be on your instructor's mind (though they have d@mn all to do with expansion). The names for the scanner and the class don't conform to Java conventions: all caps SUCK!!! The code in main() should be indented. What is supposed to happen if the user doesn't enter something that is recognisably a circle radius - like "foo" or -1?

The error detection stuff is maybe beyond where you're at. But, as jps says, how can we guess what's going through your instructor's mind? One of the things you learn posting on forums like this is that a good response is often a question. So ask your teacher what he or she means.

Re: How do I expand this code? I have no idea what my teacher wants.

i would first start by saying ur code looks a little unorganized as far as the presentation goes.... define all your variables first at the beginning of the main method, make a variable PI and set it to 3.14159 and then do all ur system.out and .nextDouble() stuff.... maybe he wants u to use JOptionPane instead of Scanner for input or put your radius variable into the Math.pow method when computing the area (all basic techniques which u should know nothin too complicated)