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

• September 3rd, 2012, 12:06 AM
Eclecstatic
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!

Code Java:

```import java.util.Scanner; public class LUCKYCAAAAT {   /** * @param args */ public static void main(String[] args) { Scanner QWERTY = new Scanner (System.in); System.out.println("Let's calculte the circumference of the circle."); System.out.println("Enter the radius of the circle."); double radius; radius = QWERTY.nextDouble(); System.out.println("You entered " + radius); System.out.println("Now calculating circumferece..."); double circumference; circumference = 2*3.14159*radius; System.out.println("The circumference of the circle is " + circumference); System.out.println("Now let's find the area!"); double area; area = 3.14159*radius*radius; System.out.println("The area of the circle is " + area);   }   }```
• September 3rd, 2012, 12:24 AM
jps
Re: How do I expand this code? I have no idea what my teacher wants.
If a student in the class does not know what the instructor wants, how is anyone else to know :-?

You could use Math.PI in place of 3.14159.

Expanding the code could turn into just about anything. I would suggest you talk to the instructor and other students to get a better understanding of what is expected in this assignment.
• September 3rd, 2012, 01:25 AM
pbrockway2
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.
• September 3rd, 2012, 10:18 PM
C++kingKnowledge
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) :)