Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: can anyone help me please to debug my simple payroll java file?

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default can anyone help me please to debug my simple payroll java file?

    i'm really need your help guy's,,i almost debug for 3-4 hours,but i can't find the solution,,only 1 error...

    this is the error: "error: reached end of file while parsing"


    and this is my java file:

    import java.io.*;
    import java.util.*;
    public class original
    {
     
    	public static void main(String[] args) throws IOException //mali pu ung (String[].args) yan kasi nakasulat kanina hehe
    	{
     
    		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 e)
     
     
     
    					//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*0.2;
    								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++;
    								}
    					}
    				}
     
    	}


    Hope someone help me..:}thank you in advance..


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,038
    Thanks
    52
    Thanked 2,280 Times in 2,251 Posts

    Default Re: can anyone help me please to debug my simple payroll java file?

    Check that the {}s are properly paired.
    Some editors have a key combo that will help. On mine I place the cursor on the { and press:
    ctrl +]

    Or print out the source and use a pencil to circle and connect the matching {}s. Start at the middle and work out.

    This has already been discussed several times at:
    simple Java error please solved..:} | DaniWeb
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can anyone help me please to debug my simple payroll java file?

    Quote Originally Posted by Norm View Post
    Check that the {}s are properly paired.
    Some editors have a key combo that will help. On mine I place the cursor on the { and press:
    ctrl +]

    Or print out the source and use a pencil to circle and connect the matching {}s. Start at the middle and work out.

    This has already been discussed several times at:
    simple Java error please solved..:} | DaniWeb
    I'm really appreaciate your help sir Norm,but can't find my error,,,wew,,headache...

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,038
    Thanks
    52
    Thanked 2,280 Times in 2,251 Posts

    Default Re: can anyone help me please to debug my simple payroll java file?

    Did you try any of my suggestions?
    Printing it on paper and using a pencil is guaranteed to work.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can anyone help me please to debug my simple payroll java file?

    yeah,i already tried,,no luck,,but i execute the codes in java eclipse,,cause i use jcreator before ,,,eclipse is good,,but still have two error,new error,,

    Scanner numin = new Scanner(System.in);
    int 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[]
    String[] day={"Tuesday","Wednesday","Thursday","Friday"}; <------error 1

    int d;

    for(d=0; d<5;d++)
    {
    String[] day;
    System.out.print("enter time in for "+day[d]+":");
    time_in=numin.hasNextDouble(); <-----error 2
    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?:");
    BufferedReader input;
    holiday = input.readLine();
    if(holiday.equals("yes")==true)
    {

    and this the error:

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    Syntax error on token "day", delete this token
    Type mismatch: cannot convert from String to String[]
    Type mismatch: cannot convert from String to String[]
    Type mismatch: cannot convert from String to String[]
    Type mismatch: cannot convert from String to String[]
    Type mismatch: cannot convert from boolean to int
    __________________________________________________ ___


    i thought only the bracket have error but codes also..wew..:}

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,038
    Thanks
    52
    Thanked 2,280 Times in 2,251 Posts

    Default Re: can anyone help me please to debug my simple payroll java file?

    What lines are those errors on? You need to post the full error messages that show the source line and the line numbers of where the errors are.
    Here is a sample:
    TestSorts.java:138: cannot find symbol
    symbol  : variable var
    location: class TestSorts
             var = 2;
             ^
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Trouble with Java payroll program
    By Shawn Wray in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 3rd, 2012, 11:57 PM
  2. How do I debug my Java applets to see what's going wrong?
    By diyaots in forum AWT / Java Swing
    Replies: 2
    Last Post: November 10th, 2011, 08:37 AM
  3. [SOLVED] Please help me with this payroll program
    By Leprechaun_hunter in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 14th, 2011, 06:47 PM
  4. Pls help me to debug this code
    By coen1604 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 24th, 2011, 09:00 AM
  5. Payroll
    By Kesh486 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 6th, 2010, 06:48 PM