Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By Norm

Thread: My nextint() is causing "symbol not found" The string lines run fine. Please help.

  1. #1
    naterptater is offline Member
    Join Date
    Aug 2011
    Posts
    2
    Rep Power
    0

    Default My nextint() is causing "symbol not found" The string lines run fine. Please help.

    import java.util.*;


    public class Grades {

    public static void main(String[] args){

    Scanner console = new Scanner(System.in);

    String sFirstName;
    String sLastName;
    String sIDnumber;

    System.out.println ("Please enter stuent ID number");
    sIDnumber = console.next();
    System.out.println ("Please enter student First Name");
    sFirstName = console.next();
    System.out.println ("Please enter student Lanst Name");
    sLastName = console.next();
    System.out.println ("Please enter grade for Assignments (Homework)");



    int iAssignment = 0; //Assignments score (Homework)
    int iQuizzes = 0; //Quzzes score
    int iMidterm = 0; //midterm score
    int iFinal = 0; //Final exam score
    int iTotal = 0; // Total score


    iAssignment = console.nextint();
    System.out.println ("Please enter grade for Quizzes");
    iQuizzes = console.nextint();
    System.out.println ("Please enter grade for Midterm");
    iMidterm = console.nextint();
    System.out.println ("Please enter grade for Final");
    iFinal = console.nextint();



    }





    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Don't just dump your code with a vague error message. Post the exact and full error message. Indicate on which line it occurs. Include the test data you use to cause the error.

    Also try debugging the code yourself. Add a print statement for each variable to see exactly what values they hold versus what you think they should hold. Of course these statements need to be before the line causing the error.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    "symbol not found"
    When you get one of these errors, go to the API doc to see if you are spelling the method correctly and giving it the correct arguments.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Arrgh!

    I thought it was a runtime error not a compile time error. This confusion would have been avoided if OP had provided better details.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    Over half the problem in answering questions is figuring out what the question is.
    DarrylBurke likes this.

  6. #6
    naterptater is offline Member
    Join Date
    Aug 2011
    Posts
    2
    Rep Power
    0

    Default Sorry, I'm new to this.

    The exact error code is:
    Grades.java:28: error: cannot find symbol
    iAssignment = console.nextint();
    ^
    symbol: method nextint()
    location: variable console of type Scanner

    for each one of my "consol.nextint () lines. The wierd thing is, when I don't close the last line of the code, those errors go away, and I only have the one error saying the code doesn't end with ;.

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Did you read reply #3 by Norm? Hint: Java is case sensitive.

  8. #8
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    Yeah, never seen the method nextint() before. Hint: Standard Java conventions say to write the name of a method like this <notCapitalized>, for classes <Capitalized>. For example, if I make a method that adds two numbers, I might call the method addNumbers(int num1, int num2).

    I'm surprised you got this far in Java and you don't know about the naming convention. Kiiiiinda important...

  9. #9
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,008
    Rep Power
    20

    Default

    Considering the number of people that post here with wildly varying coding styles I suspect that coding conventions are never actually taught.

  10. #10
    Joel's Avatar
    Joel is offline Member
    Join Date
    May 2011
    Location
    Placerville, CA
    Posts
    86
    Rep Power
    0

    Default

    So, has the solution arrived at a resolve, @naterptater? This one should be easy for you figure out...

Similar Threads

  1. Replies: 14
    Last Post: 04-08-2011, 06:01 PM
  2. Replies: 3
    Last Post: 05-21-2009, 03:48 PM
  3. Replies: 0
    Last Post: 04-02-2009, 07:02 PM
  4. Replies: 0
    Last Post: 03-15-2009, 11:53 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •