reached end of file while parsing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flibberdee
    New Member
    • Dec 2009
    • 3

    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.prin tln("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.prin tln("You have input an invalid number.");

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

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

    else
    }
    }
  • coder44
    New Member
    • Dec 2009
    • 6

    #2
    if(n > 100000 && n < 9999); --> here is a problem
    if(n > 100000 && n < 9999) ";" should not use semicolon after if

    Comment

    • flibberdee
      New Member
      • Dec 2009
      • 3

      #3
      thanks, you are right. Still having issues with the parsing.

      Comment

      • MikeWis
        New Member
        • Dec 2009
        • 1

        #4
        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!

        Comment

        • flibberdee
          New Member
          • Dec 2009
          • 3

          #5
          Originally posted by MikeWis
          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!
          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.

          Comment

          Working...