How to fix 'Symbol not found' error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JESB
    New Member
    • May 2010
    • 1

    How to fix 'Symbol not found' error

    I keep getting errors saying "symbol not found" on a couple lines.

    Code:
    int firstNumber, secondNumber, thirdNumber;
            System.out.println ("Enter First Number Here:");
            /*
             *this asks for a value to be stored into firstNumber
             *
             */
            firstNumber=keyboard.nextInt();
            /*
             *This line is incorrect says the application. The symbol cannot be found.
             *This is supposed to take the value entered through the keyboard and
             * store it into firstNumber.
             */
            System.out.println ("Enter Second Number Here:");
            secondNumber=keyboard.nextInt();
            System.out.println ("Enter Third Number Here:");
            thirdNumber=keyboard.nextInt();
            System.out.println ("Your total is" + (firstNumber + secondNumber + thirdNumber));
            System.out.println ("Your Average is" + ((firstNumber + secondNumber + thirdNumber)/3));
    the "keyboard.nextI nt()" lines keep erroring and i have no idea what to do with a "symbol" it can't find.
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    I never used this class. But probably you should use

    Code:
    readInt();
    readChar()
    functions.

    Regards
    Dheeraj Joshi

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      Where is the keyboard variable defined?
      is keyboard a Scanner?
      eg Scanner keyboard = new Scanner(System. in);

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        There are some custom classes with name Keyboard.
        I suspect OP might have used it. Or forgot to post the complete relevant code :)

        Regards
        Dheeraj Joshi

        Comment

        • jkmyoung
          Recognized Expert Top Contributor
          • Mar 2006
          • 2057

          #5
          I was guessing the symbol not found was 'keyboard' although the original post didn't specify if it was that or 'nextInt()'

          Comment

          • Dheeraj Joshi
            Recognized Expert Top Contributor
            • Jul 2009
            • 1129

            #6
            Yeah. OP might have missed it. If people use some IDE's they can know it very easily. :)

            Regards
            Dheeraj Joshi

            Comment

            • ahmee
              New Member
              • Mar 2010
              • 39

              #7
              Originally posted by JESB
              I'm taking a java course at ctu online and they're learning materials suck and the staff is even worse. I just have a really quick question on an assignment I'm doing. I keep getting errors saying "symbol not found" on a couple lines.

              Code:
              int firstNumber, secondNumber, thirdNumber;
                      System.out.println ("Enter First Number Here:");
                      /*
                       *this asks for a value to be stored into firstNumber
                       *
                       */
                      firstNumber=keyboard.nextInt();
                      /*
                       *This line is incorrect says the application. The symbol cannot be found.
                       *This is supposed to take the value entered through the keyboard and
                       * store it into firstNumber.
                       */
                      System.out.println ("Enter Second Number Here:");
                      secondNumber=keyboard.nextInt();
                      System.out.println ("Enter Third Number Here:");
                      thirdNumber=keyboard.nextInt();
                      System.out.println ("Your total is" + (firstNumber + secondNumber + thirdNumber));
                      System.out.println ("Your Average is" + ((firstNumber + secondNumber + thirdNumber)/3));
              
              the "keyboard.nextInt()" lines keep erroring and i have no idea what to do with a "symbol" it can't find.
              Code:
              try this my frd...this a simple way to find the average...and in your code in sop statement you are jus print the statement.you have to first declare a p.data type for the varaible and set the function in it and then call it through SOP statement...here is my code it will help you alot to understand...if had any query hit me....
              
              import javax.swing.*;
              class findAverge{
              
              public static void main(String[] args){
              
              int firstNumber, secondNumber, thirdNumber;
              firstNumber=Integer.parseInt(JOptionPane.showInputDialog("enter first Number"));
              System.out.println("firstNumber =" + firstNumber);
              
              secondNumber=Integer.parseInt(JOptionPane.showInputDialog("enter second number"));
              System.out.println("secondNumber =" + secondNumber);
              
              thirdNumber=Integer.parseInt(JOptionPane.showInputDialog("entert third number"));
              System.out.println("thirdNumber =" + thirdNumber);
              
              int total=firstNumber+secondNumber+thirdNumber;
              System.out.println("your total =" +total);
              
              float average= total/3;
              System.out.println("your average is ="+average);
              
              
              }}

              Comment

              Working...