• Post Reply Bookmark Topic Watch Topic
  • New Topic

reached end of file while parsing  RSS feed

 
Channing Johnson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep getting this error and can not fix! Help please!!! Code below...

C:\Users\Amy\Desktop\Assignment Week 2\src\assignment\week\pkg2\JCalc.java:47: error: reached end of file while parsing
        }
1 error
C:\Users\Amy\Desktop\Assignment Week 2\nbproject\build-impl.xml:930: The following error occurred while executing this line:
C:\Users\Amy\Desktop\Assignment Week 2\nbproject\build-impl.xml:270: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)


 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Always tell the full details about any errors. We can help better if we know what is going on.
What's Tsubo?
Don't use \n (even though you can see it in many books). Take the \n out and use System.out.println instead. If you use printf use the %n tag instead. If you use printf, you will want a tag for the area, but I shall leave you to find out about printf for yourself.
You have a lot of repeated code in libnes 33‑43. you should think of how to get rid of the repetition.
Beware of mixing nextLine and nextInt with Scanners. All will be well until you go back and try nextLine after nextInt, when there will be a poorly‑documented Exception.
Why are you importing PrintStream? You won't need to declare a PrintStream for a long time. You don't need a PrintStream variable anywhere. You can do everything by writing System.out.something. You are even trying to assign your PrintStream to System.out.print(something) and the compiler won't like that.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you get a reached end of file error message, you have got too few }s or too many {s. Since you seem to be using NetBeans, I am surprised; I thought NetBeans would have matched the {} for you automatically.
 
praveen kumaar
Ranch Hand
Posts: 461
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a syntax error.try to count closing and opening curly braces in your code,you will find the difference.
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In NetBeans and Eclipse, you can autoformat your code by pressing Alt+Shift+F.  This will indent your code properly and align matching braces with the control structure (loop, if, method, class) that they belong to. This will make it easier for you to see where you're missing a matching brace.

The brace on line 39 should be removed as it is redundant -- it will only confuse you more.
 
Channing Johnson
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for the help and pointers!!! I have corrected the silly error and took all of your helpful hints into consideration to revise this program!!! Thank you!
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote:. . . The brace on line 39 should be removed as it is redundant -- it will only confuse you more.
Are you sure it is redundant? Unnecessary? As opposed to part of an else statement with the else keyword missing?
 
Junilu Lacar
Sheriff
Posts: 11493
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Are you sure it is redundant? Unnecessary? As opposed to part of an else statement with the else keyword missing?

I didn't really read the code in detail, just looked at the structure and matching braces. Since there was no executable else, I assumed the braces were not connected to the if above it. I don't pay much attention to comments any more so I tend to ignore them, especially ones in the body of a method. Now that you say so, however, you're probably right about there being a missing else before that brace.
 
Liutauras Vilda
Sheriff
Posts: 4918
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@OP

Regardless of syntax errors, I'd worry more about the program structure and the way you build your programming habits.

What I have in mind are: misleading comments, unecessary comments, unclear package naming, class naming, more importantly chosen poor variable names. Bad code formatting and indentation.
All those have not much to do with the program's logic itself, but getting them wrong complicates everything else. So build up your good habits and pay more attention to it.

Some suggestions:
Package statement would read better as assignment.week.calculator/converter
Class name would sound probably better as LengthConverter. At least this is what you are trying to achieve I think.

Also try to create a method (with self explaining name) for those conversions rather than repeat same code over and over.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!