Results 1 to 10 of 10
- 08-02-2011, 02:43 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 2
- Rep Power
- 0
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();
}
}
- 08-02-2011, 03:06 AM #2
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.
- 08-02-2011, 03:14 AM #3
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."symbol not found"
- 08-02-2011, 03:21 AM #4
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.
- 08-02-2011, 03:29 AM #5
Over half the problem in answering questions is figuring out what the question is.
- 08-02-2011, 05:16 AM #6
Member
- Join Date
- Aug 2011
- Posts
- 2
- Rep Power
- 0
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 ;.
- 08-02-2011, 05:27 AM #7
Did you read reply #3 by Norm? Hint: Java is case sensitive.
- 08-03-2011, 01:03 AM #8
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...
- 08-03-2011, 09:38 AM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Considering the number of people that post here with wildly varying coding styles I suspect that coding conventions are never actually taught.
- 08-03-2011, 05:05 PM #10
Similar Threads
-
Exception in thread "main" java.lang.NumberFormatException:input string: "060320
By renu in forum New To JavaReplies: 14Last Post: 04-08-2011, 06:01 PM -
How can I prevent "found void but expected java.lang.String" ?
By trueblue in forum New To JavaReplies: 3Last Post: 05-21-2009, 03:48 PM -
final String currentWorld = "Java Forums"; String.format("Hello %s", currentWorld);
By mcfrog in forum IntroductionsReplies: 0Last Post: 04-02-2009, 07:02 PM -
"Cached Item Was Locked" causing Select Statement: Hibernate + EHCache
By cloutierm in forum Advanced JavaReplies: 0Last Post: 03-15-2009, 11:53 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks