1,105,340 Community Members

simple Java error please solved..:}

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i have encounter problem on my java file,i can't find the solution..just only one error..

here is the java file and it give me an error of error: "reached of end of file while parsing in line 137"

can anyone help me please?thanks in advance..

import java.io.*;
import java.util.*;
public class original
{

public static void main(String[] args) throws IOException 
{

    int loop=0;
    while(loop<3)
    {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String employee_code="";
        String employee_level="";
        String employee_name="";
        String tex="";
        double rate=0;

        System.out.println("input employee codes");
        employee_code = input.readLine();

    }
    BufferedReader con = new BufferedReader(new FileReader("employee.txt"));
    String str;
    int ctrlen=0;

    while((str=con.readLine())!=null)
    {
        ctrlen=ctrlen+1;
    }
    con.close();

    BufferedReader con1=new BufferedReader(new FileReader("employee.txt"));
    String strlo[] = new String[ctrlen];
    int ctr=0;

    while((str=con1.readLine())!=null)
    {
        strlo[ctr]=str;
        ctr++;
    }
    con1.close();
            for(int a=0;a<ctrlen;a++){
                if(strlo[a].equals(employee_code)==true)
                //dito yata yung Try hehe
                    try{
                    employee_level=strlo[(a+1)];
                    employee_name=strlo[(a-1)];
                    tex=strlo[a];

            }

            catch(Exception Enum)
                //dpat may { po after ng Catch statement
                {System.out.println("error");
                            if(employee_level.equals("level1")==true)
                            {
                                rate = 380;
                                double gsismul=.10;

                            }
                            else if(employee_level.equals("level1")==true)
                            {
                                rate = 450;
                                double gsismul=.15;

                            }
                            else
                            {
                                rate=500;
                                double gsismul=.2;
                            }
                            if (tex.equals(employee_code)==true)
                            {
                                System.out.println("employee name" + employee_name);
                                System.out.println("employee name" + employee_name);
                                System.out.println("employee name" + employee_level);

                                Scanner numin = new Scanner(System.in);
                            double time_in=0;
                            double time_out=0;
                            double total_time_per_day=0;
                            double total_worked_hours=0;
                            double ot_in=0;
                            double ot_out=0;
                            double total_ot_per_day=0;
                            double total_ot=0;
                            double holiday_pay=0;
                            String holiday="";
                            String day={"Monday","Tuesday","Wednesday","Thursday","Friday"};
                            int d;

                            for(d=0; d<5;d++)
                            {
                                System.out.print("enter time in for "+day[d]+":");
                                time_in=numin.nextdouble();
                                System.out.print("enter time out for"+day[d]+":");
                                time_out=numin.nextDouble();
                                //Kulang ng isang " po...
                                System.out.print("is"+day[d]+"a holiday?:");
                                holiday = input.readLine();
                                if(holiday.equals("yes")==true)
                                {
                                    holiday_pay=holiday_pay+1;
                                }       
                                    else
                                    {
                                        holiday_pay=holiday_pay+0;
                                    }
                                    System.out.print("enter over time in for"+day[d]+":");
                                    ot_in=numin.nextDouble();
                                    System.out.print("Enter over time out for "+day[d]+":");
                                    ot_out=numin.nextDouble();
                                                    original
                                        total_time_per_day=time_out-time_in;
                                        total_worked_hours=total_worked_hours + total_time_per_day;
                                        total_ot_per_day=ot_out - ot_in;
                                        total_ot=total_ot+total_ot_per_day;

                            }
                            total_worked_hours=total_worked_hours/100;
                            total_ot=total_ot/100;
                            double rate_per_day=rate/8;
                            double gross_income=total_worked_hours*rate_per_day;
                            double doublepay=holiday_pay*rate;
                            double sss=gross_income*0.10;
                            double gsis=gross_income*gsismul;
                            double total_deduction=sss+gsis;
                            double allowance=500;
                            double total_salary=gross_income+total_ot_income+doublepay+allowance;
                            double net_income=total_salary-total_deduction;
                            System.out.print("net income"+net_income);
                            loop = loop+4;

                            }
                            else{
                                System.out.println("error code");
                                loop++;
                            }
                }
            }
        }
Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

Check that all the {}s are properly paired.

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i think it's properly paired,i try more times..

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

The compiler does a very thorough job. Check again.

You have too much code in the catch block. set a flag to remember a condition and exit to handle the processing outside of the catch.

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

still error,

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
0
 

In the changes you made did you check if you have a closing bracket for the public class?

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

Add a } at the end and compile. If you get the same error do it again.

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i already try to add } at the end,,and errors become 29.....

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

Please post the full text of the error messages.

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

when i add again a } at the end,the error now is 1

"error:class,interface,or enum expected"

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
0
 

,and errors become 29.....

don't initialize variables inside a loop/condition

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

You need to post the full text of the compiler error messages.

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
0
 

when i add again a } at the end,the error now is 1

"error:class,interface,or enum expected"

you added an unnecessary closing bracket, check all the brackets again

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

wew,still error,,oh,,i'm really weak in debugging..

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 

You need to post the full text of the compiler error messages.

Member Avatar
poojavb
Posting Pro
524 posts since Nov 2011
Reputation Points: 29 [?]
Q&As Helped to Solve: 78 [?]
Skill Endorsements: 9 [?]
 
0
 

When I added ur block of comment in eclipse and tried to execute it ...it showed a lot of errors for variables like total_ot_income is not resolved and many so on.....One closing brace bracket is missing at the end also...try to paste the complete code again and also the error msgs....and what;s in ur text file the employee info??

Member Avatar
NormR1
Posting Sage
7,723 posts since Jun 2010
Reputation Points: 563 [?]
Q&As Helped to Solve: 793 [?]
Skill Endorsements: 16 [?]
Team Colleague
 
0
 
Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

yup the employee code

Member Avatar
anuj6928
Junior Poster in Training
70 posts since Jul 2010
Reputation Points: 5 [?]
Q&As Helped to Solve: 8 [?]
Skill Endorsements: 0 [?]
 
0
 

"reached of end of file while parsing in line 137"

can anyone help me please?thanks in advance..

CHeck the Brackets.... the code ere iz going fine

Member Avatar
breakzzzz20
Junior Poster in Training
60 posts since Jan 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

so only the Brackets have a error?i thought the codes also..:}will check 100% the bracket

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article