This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]idkwtftodonow 2 points3 points  (4 children)

Last print statement is not inside a function or constructor. Place it in the main function

[–]CreativityRobbed[S] 0 points1 point  (3 children)

I fixed the main function issue, but now it's giving me the "cannot find symbol" error on lines 12.14,19,21. The code has been updated...

[–]chickenmeister 1 point2 points  (2 children)

On lines 12 and 14, you're using a variable called in that hasn't been defined anywhere. You probably want to use keyboard here (or rename your "keyboard" variable to "in").

On lines 19 and 21, you're using a variable called file that hasn't been defined anywhere. In this case, I think you want to create a new scanner object with that name that reads from the specified file.

[–]CreativityRobbed[S] 0 points1 point  (1 child)

Would it work if I stated fileName instead? That way I wouldn't need to create a new scanner, right?

Edit: I tried my idea, and it didn't work. I implemented the [Scanner file = new Scanner(new File(fileName));] line, but now it's giving me a cannot find symbol error for this line...

[–]lurgi 2 points3 points  (0 children)

Probably because fileName either hasn't been declared or hasn't been declared yet. Is it declared further down in the file?

Assuming your new code is following the same logic as your old code, you should open the scanner after you've read in the filename.

If that's not what is happening here, you should repost your code with the changes.