Welcome to the Java Programming Forums


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.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post 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!

    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);
     
    	}
     
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default 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.

  3. #3
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default 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.

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    71
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default 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)

Similar Threads

  1. Replies: 2
    Last Post: September 2nd, 2012, 02:06 PM
  2. Looking for A Java Teacher
    By BigBoi2010 in forum Object Oriented Programming
    Replies: 3
    Last Post: June 7th, 2012, 10:43 AM
  3. No idea how to fix it.
    By Hammer67 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 13th, 2011, 10:41 AM
  4. Having trouble understanding what teacher said for build Tree.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 16th, 2010, 08:22 PM
  5. The Problem With My Code Is That It Doesn't Exist Yet. (Help w/ Retarded Teacher)
    By DylanWilliams92 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 27th, 2010, 08:10 PM