1.11M Members

simple Java error please solved..:}

 
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++;
                            }
                }
            }
        }
 
0
 

Check that all the {}s are properly paired.

 
0
 

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

 
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.

 
0
 

still error,

 
0
 

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

 
0
 

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

 
0
 

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

 
0
 

Please post the full text of the error messages.

 
0
 

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

"error:class,interface,or enum expected"

 
0
 

,and errors become 29.....

don't initialize variables inside a loop/condition

 
0
 

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

 
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

 
0
 

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

 
0
 

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

 
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??

 
0
 

yup the employee code

 
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

 
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