C:\Documents and Settings\Elliona\Desktop\kirby>javac payrollsystem.java
payrollsystem.java:166: '}' expected
filter.close();
^
1 error

here is my full code

import java.io.*;
import java.util.*;


public class payrollsystem{
    public static void main(String args[]) throws Exception {

    File employee = new File("employee.txt");
    File dtr = new File("dtr.txt");
    PrintWriter pw = new PrintWriter(dtr);
    Scanner filter = new Scanner(employee);
    Scanner datain = new Scanner(System.in);
    
    String empCode, empName, empLevel;
    String covDate, covMonth, covYear;
    String days[] = {"Monday","Tuesday","Wednesday","Thursday","Friday"};
    String option;
    
    double empSalRate;
    double timeInA=0,timeOutA=0;
    double minLate=0,rph=0,dailyTime=0,weeklyTime=0;
    double dailyIncome=0,weeklyIncome=0,weeklyNet=0,weeklyIncomeA=0;
    double totalOt=0,otIncome=0,otTime=0,tax=0,sss=0,deductions=0,allowance=500;;
    double otIn,otInA=0,otOut,otOutA=0;
    int ctr=0;
    int timeIn, timeOut;

    //Asking for an employee Code:!!!!!!!!!!!!!!!!!!
    System.out.print("Enter an Employee Code:");
    empCode=datain.nextLine();

    
    while(filter.hasNext()){
        if(empCode.equals(filter.nextLine())){
        empName=filter.nextLine();
        empLevel=filter.nextLine();
        empSalRate=filter.nextDouble();

        System.out.println("*************************************");
        System.out.println("Employee Name:"+empName);
        System.out.println("Employee Level:"+empLevel);
        System.out.printf("Salary Rate :Php%.2f\n",empSalRate);
        System.out.println("*************************************");

        pw.println("***********************************");
        pw.println("Employee Code:"+empCode);
        pw.println("Employee Name:"+empName);
        pw.println("Employee Level:"+empLevel);
        pw.println("Salary Rate :Php"+empSalRate+"0");
        pw.println("***********************************");
    
    //Asking for timeIn and timeOut and screening undertime and late:!!!!!!
    
    do {
        System.out.println("------------------------------");
        System.out.print("Enter time in for "+days[ctr]+":");
        timeIn=datain.nextInt();
            if(timeIn>=1700)
                timeInA = 1700;
            else if(timeIn>=1600)
                timeInA = 1600;
            else if(timeIn>=1500)
                timeInA = 1500;
            else if(timeIn>=1400)
                timeInA = 1400;
            else if(timeIn>=1300)
                timeInA = 1300;
            else if(timeIn>=1200)
                timeInA = 1200;
            else if(timeIn>=1100)
                timeInA = 1100;
            else if(timeIn>=1000)
                timeInA = 1000;
            else if(timeIn>=900)
                timeInA = 900;
            else if(timeIn>=800)
                timeInA = 800;
            else if(timeIn<=800)
                {timeInA = 800;
                timeIn = 800;}
        pw.println("Enter time in for "+days[ctr]+"\t:"+timeIn);

        System.out.print("Enter time out for "+days[ctr]+":");
        timeOut=datain.nextInt();
            if(timeOut>=1700)
                timeOutA = 1700;
            else if(timeOut>=1600)
                timeOutA = 1600;
            else if(timeOut>=1500)
                timeOutA = 1500;
            else if(timeOut>=1400)
                timeOutA = 1400;
            else if(timeOut>=1300)
                timeOutA = 1300;
            else if(timeOut>=1200)
                timeOutA = 1200;
            else if(timeOut>=1100)
                timeOutA = 1100;
            else if(timeOut>=1000)
                timeOutA = 1000;
            else if(timeOut>=900)
                timeOutA = 900;
            else if(timeOut>=800)
                timeOutA = 800;
            else if(timeOut<=800)
                {timeOutA = 800;
                 timeOut = 800;}
        pw.println("Enter time out for "+days[ctr]+"\t:"+timeOut);

        //Formula for dailyTime, weeklyTime and Late:!!!!!!!!!!!!!!!!
        if(timeIn>=1300) {
            minLate=0;
            dailyTime=((timeOutA-timeInA)/100)-minLate;
        }
        else {
            minLate=(timeIn-timeInA)/60;
            dailyTime=(((timeOutA-timeInA)/100)-minLate)-1;
        }
        rph=empSalRate/8;
        dailyIncome=dailyTime*rph;
        weeklyTime=weeklyTime+dailyTime;
        weeklyIncome=weeklyIncome+dailyIncome;
    
            System.out.println("*******************************");    
            System.out.print("Enter Coverage Date: ");
            covMonth=datain.next();
            covDate=datain.next();
            covYear=datain.next();

            otIncome=(totalOt*rph)*1.1;
            weeklyIncomeA=(weeklyIncomeA+otIncome);
            tax=weeklyIncome*.1;
            sss=weeklyIncome*.01;
            deductions=(tax+sss);
            weeklyNet=(weeklyIncomeA-deductions)+allowance;
            pw.println("********************************");
            pw.print("Enter Coverage Date: ");
            System.out.print(" ");
            
        System.out.println("========================================");
        System.out.println("========  TESDA Payroll System   =======");
        System.out.println("========================================");
        System.out.println("Employee Name: "+empName);
        System.out.println("Employee Code: "+empCode);
        System.out.println("Employee Level: "+empLevel);
        System.out.printf("Salary Rate :Php %.2f",empSalRate);
        System.out.println("/day");

        System.out.println("*****************************************");
        System.out.println("Date Covered\t: "+covMonth+" "+covDate+","+covYear);
        System.out.printf("TOtal Number of Work Hours: %.0f",weeklyTime);
        System.out.println(" Hours");
        System.out.printf("OverTime Hours\t: %.0f",totalOt);
        System.out.println(" Hourse");
        System.out.printf("Regular Income\t: "+"Php %.2f\n",weeklyIncome);
        System.out.printf("OverTime Income\t: "+"Php %.2f\n",otIncome);
        System.out.printf("Gross Income\t: "+"Php %.2f\n",weeklyIncomeA);
        System.out.println("Deductions:");
        System.out.printf(" *Tas: %.2f\n",tax);
        System.out.printf(" *SSS: %.2f\n",sss);
        System.out.println("******************************************");
        System.out.printf("****  Net Income: Php %.2f",weeklyNet);
        System.out.println(" *********");
        System.out.println("******************************************");
        pw.close();
        filter.close();

Recommended Answers

All 3 Replies

On line 166 it expects a } (was that so hard to understand?)
It's because you dont have a } to close your method, nor one to close your class definition.

There is nothing wrong with the Error. It is 100% correct. Your code is wrong. (As noted above.)

you should study about do while loop...

do
{
}
while(condition);

this is syntax...

but what you done is very blind...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.