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: User input trouble

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default User input trouble

    Hi all,

    First time poster from Ireland here.

    Anything i know from programming is based off a very quick dip into codeacademy and the first lecture given thus far.

    Below is my code for taking the radius of a circle from the user and then going ahead to give radius, area, circumference.

    I keep getting a "couldn't find symbol" error when compiling, which i have hunted down to be an issue with my variables.

    For the life of my i cannot figure out how to get the scanner element working.

    Any and all advice is welcome,

    CC.



    import java.util.scanner;
    class CalculateCircleUserInput
    {
    public static void main(String[] args)
    {
    Scanner radius = new Scanner(System.in);
    System.out.println("Please input the circle's radius: ");
    double radius = radius.nextdouble();
    double pi = 3.1416;
    double area = pi*radius*radius;
    double circumference = pi*radius*2;

    System.out.println("You have defined the circle's radius as: " + radius);
    System.out.println("It's area is " + area);
    System.out.println("It's circumference is " + circumference);
    }
    }


  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: User input trouble

    You have a Scanner called radius and a double called radius. You have confused the compiler. Make sure your variables have unique names. The next error you'll run into is a method is not defined/cannot find symbol message. Java is case sensitive. I'll leave it to you to find the cause.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: User input trouble

    Hi,

    Thanks for that. Problem(s) solved.

    I'm still getting to grip with how sensitive code is.

    Cheers,

    CC.

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: User input trouble

    Oh, code isn't sensitive, the compiler is dead stupid and only works properly if you have every single character correct

Similar Threads

  1. User Input help
    By dx2731 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 13th, 2013, 12:46 AM
  2. Trouble calculating a product and allowing a user to specify a range
    By jetset22 in forum Object Oriented Programming
    Replies: 1
    Last Post: February 5th, 2013, 01:58 PM
  3. User Input help
    By lanmonster in forum What's Wrong With My Code?
    Replies: 20
    Last Post: January 20th, 2013, 10:44 AM
  4. Take user input
    By frabbi.cse in forum Java Theory & Questions
    Replies: 1
    Last Post: July 22nd, 2012, 12:48 PM
  5. File Input Trouble
    By mael331 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 13th, 2012, 06:38 AM