473,322 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

reached end of file while parsing

I keep getting this error when I try to build my project. I have checked I have two opening { and two closing }. I cant for the life of me figure out what is wrong with this code. I am fairly new to java and yes this is for a class. I just need help figuring out this error.

import java.util.*;
class Divisibility
{
public static void main(String args[])
{
int n, sum, digit1, digit2, digit3, digit4, digit5; //Declaring my variables.

Scanner input = new Scanner(System.in);
System.out.println("Please enter a 5 digit number.");
n = input.newInt();

if
(n > 100000 && n < 9999); //Checking to make sure they entered a 5 digit number.
System.out.println("You have input an invalid number.");

digital1 = n/10000;
digital2 = n%10000/1000;
digital3 = n%10000%1000/100;
digital4 = n%10000%1000%100/10;
digital5 = n%10000%1000%100%10/1;

System.out.println("You have input an invalid number.");
float div, div2;
sum = digit1 + digit2 + digit3 + digit4 + digit5;
System.out.println("The sum of the digits is /t" +sum);
div = sum%3;
div2 = n%3;
if(div == 3 && div2 == 3)
System.out.println("Both /t" +n+"and /t" +sum+ "are divsible by 3.");
else
System.out.println(n+ "/t and /t" +sum+ "/t are indivisible by 3.");
if(div == 3 && div2 !=3)
System.out.println("The famous statement is wrong!");
else
if(div != 3 && div2 == 3)
System.out.println("The famouse statement is wrong!");

else
}
}
Dec 6 '09 #1
4 2418
if(n > 100000 && n < 9999); --> here is a problem
if(n > 100000 && n < 9999) ";" should not use semicolon after if
Dec 6 '09 #2
thanks, you are right. Still having issues with the parsing.
Dec 6 '09 #3
Your very last 'else' statement is causing the problem. Change that line to

else { }

to indicate to the compiler that the first closing bracket is not in fact the first line if your else statement.

Once you do that, you have some other problems to work out, but those are much more straightforward. Hope this helped!
Dec 8 '09 #4
@MikeWis
Hey thanks alot. I then got errors on my int's and then I am like man I cant believe I didnt see I had misspelled them when I called for them later. DUR!!!

Thanks again.
Dec 8 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
2
by: Oxmard | last post by:
Armed with my new O'Reilly book Optimizing Oracle Performance I have been trying to get a better understanding of how Oracle works. The book makes the statement, " A database cal with dep=n + 1...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
7
by: christian.eickhoff | last post by:
Hi Everyone, I am currently implementing an XercesDOMParser to parse an XML file and to validate this file against its XSD Schema file which are both located on my local HD drive. For this...
5
by: baskarpr | last post by:
Hi all, I my program after parsing in SAX parser, I want to write the parse result as an XML file. I want to ensure that there should be no difference between source XML file and parse result xml...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
7
by: souravmallik | last post by:
Hello, I'm facing a big logical problem while writing a parser in VC++ using C. I have to parse a file in a chunk of bytes in a round robin fashion. Means, when I select a file, the parser...
3
by: spittinfire | last post by:
-------------------------------------------------------------------------------- I am trying to correct the errors on an assignment that has already been graded because I have to now modify it and...
1
by: kk975kom | last post by:
Hi can somebody help me ,iam trying to compile my java program but display error was reached end of file while parsing .please find the error in program.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.