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

Thread: Cannot add values

  1. #1
    Member
    Join Date
    Jul 2013
    Location
    Baltimore, MD
    Posts
    59
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default Cannot add values

    for: double mediumSubTotal, I want to declare MEDIUM_RATE * medium + childSubTotal, but it's giving me a syntax error "cannot find symbol" when I try to add childSubTotal

    private void childButtonMouseClicked(java.awt.event.MouseEvent evt) {                                         
     
            childCounter++;
            childQuantity.setText(String.valueOf(childCounter));
     
            int child = Integer.parseInt(childQuantity.getText());
            double childSubTotal = CHILD_RATE * child;
            double childTax = childSubTotal * MD_STATE_TAX;
            double childTotal = childSubTotal + childTax;
     
            subTotal.setText(String.valueOf(fmt.format(childSubTotal)));
            tax.setText(String.valueOf(fmt.format(childTax)));
            total.setText(String.valueOf(fmt.format(childTotal)));
     
        }                                        
     
        private void mediumButtonMouseClicked(java.awt.event.MouseEvent evt) {                                          
     
            mediumCounter++;
            mediumQuantity.setText(String.valueOf(mediumCounter));
     
            int medium = Integer.parseInt(mediumQuantity.getText());
            double mediumSubTotal = MEDIUM_RATE * medium;
            double mediumTax = mediumSubTotal * MD_STATE_TAX;
            double mediumTotal = mediumSubTotal + mediumTax;
     
            subTotal.setText(String.valueOf(fmt.format(mediumSubTotal)));
            tax.setText(String.valueOf(fmt.format(mediumTax)));
            total.setText(String.valueOf(fmt.format(mediumTotal)));
     
        }


  2. #2
    Member GoodbyeWorld's Avatar
    Join Date
    Jul 2012
    Location
    Hidden command post deep within the bowels of a hidden bunker somewhere under a nondescrip building
    Posts
    161
    My Mood
    Stressed
    Thanks
    14
    Thanked 25 Times in 25 Posts

    Default Re: Cannot add values

    childSubTotal is local to the first method. It goes away outside the method.

  3. #3
    Member
    Join Date
    Jul 2013
    Location
    Baltimore, MD
    Posts
    59
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default Re: Cannot add values

    Quote Originally Posted by GoodbyeWorld View Post
    childSubTotal is local to the first method. It goes away outside the method.
    Is it because the first method is private? How can I fix this?

    I'm using NetBeans GUI builder

    --- Update ---

    Solved

Similar Threads

  1. Replies: 2
    Last Post: October 26th, 2013, 09:56 AM
  2. Replies: 2
    Last Post: October 26th, 2013, 09:56 AM
  3. add values in JTable
    By viper_pranish in forum AWT / Java Swing
    Replies: 3
    Last Post: July 27th, 2013, 08:16 AM
  4. [SOLVED] compare form values with database values
    By VaniRathna in forum Java Servlet
    Replies: 2
    Last Post: October 24th, 2011, 02:48 AM
  5. Character Values Inside of Number Values
    By bgroenks96 in forum Java Theory & Questions
    Replies: 4
    Last Post: October 2nd, 2011, 08:27 PM