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 2 of 2

Thread: I'm new and I'm Stuck

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I'm new and I'm Stuck

    This might be easy for some of y'all, but I'm very new and I'm stuck. I'm not sure how to get past this.
    public class JavaClass{
             public static void main (String [] args){
     
                System.out.println("Welcome to Matthew Galetti's Rectangle and Square Calculator");
     
                //System.out.println("Rectangle Width Value");
                //int number = 6;
                //System.out.print(number);
     
     
                //System.out.println("Rectangle Length Value");
                //int number2 = 20;
                //System.out.print(number2);
     
     
                System.out.println("The Area of the Rectangle is 120");
                int product = number * number2;
                //20*6=120
                int number = 120;
                System.out.print(product);
     
                System.out.println("The Perimeter of the Rectangle is 52");
                int sum = number + number + number2 + number2;
                //6+6+20+20=52
                int number = 52;
                System.out.print(sum);




    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    JavaClass.java:21: error: cannot find symbol
    int product = number * number2;
    ^
    symbol: variable number
    location: class JavaClass
    JavaClass.java:21: error: cannot find symbol
    int product = number * number2;
    ^
    symbol: variable number2
    location: class JavaClass
    JavaClass.java:27: error: cannot find symbol
    int sum = number + number + number2 + number2;
    ^
    symbol: variable number2
    location: class JavaClass
    JavaClass.java:27: error: cannot find symbol
    int sum = number + number + number2 + number2;
    ^
    symbol: variable number2
    location: class JavaClass
    JavaClass.java:29: error: variable number is already defined in method main(String[])
    int number = 52;
    ^
    5 errors

    all those errors marks are underneath the n's in the N's in the word numbers. When I put it into the post they didn't come out that way.
    Last edited by Geedep14; November 11th, 2018 at 07:58 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,325
    Thanks
    53
    Thanked 2,393 Times in 2,347 Posts

    Default Re: I'm new and I'm Stuck

    JavaClass.java:21: error: cannot find symbol
    int product = number * number2;
    ^
    symbol: variable number
    The compiler can not find a definition for the variable number for the statement on line 21.
    Make sure number is defined before trying to use it.

    The same for the other cannot find symbol errors.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Need help STUCK
    By mstratmann in forum Loops & Control Statements
    Replies: 7
    Last Post: May 3rd, 2013, 08:25 AM
  2. Please Help I'm stuck
    By mael331 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 6th, 2011, 09:02 AM
  3. Im stuck, please help
    By bigsmoke101 in forum Loops & Control Statements
    Replies: 3
    Last Post: April 12th, 2011, 04:34 PM
  4. Stuck again
    By Tate in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 28th, 2010, 10:22 AM
  5. Stuck help please!
    By mindlessn00b in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 5th, 2010, 05:31 PM