import java.util.*;
import java.io.*;
import java.text.*;
class salary
{ public double sals(double rate,double hrs)
{ double sal=0;
sal=(rate*hrs)/8; return sal; }
}
class time_in_hrs
{ public int inhrs(int hrs)
{int gen_in_minus=0;
if(hrs <= 814)
{ gen_in_minus =4; }
else
{ gen_in_minus = 12 - (hrs/100); }
return gen_in_minus; }
}
class time_out_hrs
{ public int outhrs(int hrs)
{ int gen_out_minus = 0;
gen_out_minus=(hrs/100) - 13; return gen_out_minus; }
}
class time_in_mins
{ public double mins(int hrs)
{ int tmins=0;
if(hrs <= 814){ tmins=0; }
else{ tmins = hrs % 100; }
return tmins; }
}
class time_out_mins
{ public double mouts(int hrs)
{ int tmins=0,m=0;
tmins = hrs % 100;
if(tmins == 0) { m=0; }
else { m = 60 - tmins; }
return m; }
}
class flx_hrs
{ public int flxinhrs(int hrs)
{int gen_in_minus=0;
gen_in_minus = hrs/100; return gen_in_minus; }
}
class flx_mins_in
{ public double flxminsin(int hrs)
{ int tmins=0;
if(hrs < 814) { tmins=0; }
else { tmins = hrs % 100; }
return tmins; }
}
class flx_mins_out
{ public double flxminsout(int hrs)
{ int tmins=0,m=0;
tmins = hrs % 100;
if(tmins == 0) { m=0; }
else
{ m = 60 - tmins; }
return m; }
}
public class payroll123{
public static void main(String[] args) throws IOException
{
String code, str;
double rate=0,totalh=0,total=0;
double salar=0;
time_in_hrs nhrs1=new time_in_hrs();
time_out_hrs ohrs1=new time_out_hrs();
time_in_mins inmins1=new time_in_mins();
time_out_mins outmins1=new time_out_mins();
flx_hrs nnhrs1=new flx_hrs();
flx_mins_in nmins1=new flx_mins_in();
flx_mins_out omins1=new flx_mins_out();
salary sal1=new salary();
int inhrs1,othrs1,total_hrs1=0,total_hrs2=0,total_flxhrs1=0,total_flxhrs2=0,a_flxhrs=0;
double nnmins1,onmins1,total_mins1=0,total_mins2=0,totmins=0,summins=0,thm=0;
double t1=0,t2=0,t3=0,t4=0,t5=0;
FileReader fr = new FileReader("employee.txt");
BufferedReader br = new BufferedReader(fr);
FileWriter fw = new FileWriter("dtr.txt",true);
BufferedWriter bw = new BufferedWriter(fw);
NumberFormat nf = new DecimalFormat("#0.00");
System.out.print("\t\t Linda Marketing Payroll System");
System.out.print("\n\n");
System.out.print("Enter Code: ");
Scanner sc = new Scanner(System.in);
code = sc.next();
while((str = br.readLine())!=null)
{
String[]arr = str.split(",");
if (code.equals(arr[1]))
{
System.out.println("Employee name: "+arr[0]);
System.out.println("Employee Code: "+arr[1]);
System.out.println("Employee Level: "+arr[2]);
if (arr[2].equals("1"))
{
rate= 380.00;
System.out.println("Employee Rate: "+rate);
}
if(arr[2].equals("2"))
{
rate= 480.00;
System.out.println("Employee Rate: "+rate);
}
if (arr[2].equals("3"))
{
rate= 550.00;
System.out.println("Employee Rate: "+rate);
}
System.out.println(" Monday");
System.out.print(" Log_in: ");
Scanner sc1 = new Scanner(System.in);
String loginmon = sc1.next();
String []arr1 = loginmon.split(":");
String comloginmon = arr1[0]+arr1[1];
int conloginmon = Integer.parseInt(comloginmon);
nnmins1=inmins1.mins(conloginmon);
System.out.println(" Monday ");
System.out.print(" Log_out: ");
Scanner sc2 = new Scanner(System.in);
String logoutmon = sc2.next();
String []arr2 = logoutmon.split(":");
String comlogoutmon = arr2[0]+arr2[1];
int conlogoutmon = Integer.parseInt(comlogoutmon);
onmins1=outmins1.mouts(conlogoutmon);
if(conloginmon>= 800 && conlogoutmon <= 1200)
{
inhrs1 = nnhrs1.flxinhrs(conloginmon);
othrs1 =nnhrs1.flxinhrs(conlogoutmon);
nnmins1 = nmins1.flxminsin(conloginmon);
onmins1 = omins1.flxminsout(conlogoutmon);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
a_flxhrs = total_hrs2 - total_hrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
thm = (total_flxhrs2 - total_flxhrs1)-a_flxhrs;
t1=(thm-summins);
}
else if(conloginmon>= 1300 && conlogoutmon <= 1700)
{
inhrs1= nnhrs1.flxinhrs(conloginmon);
othrs1 = nnhrs1.flxinhrs(conlogoutmon);
nnmins1 = nmins1.flxminsin(conloginmon);
onmins1 = omins1.flxminsout(conlogoutmon);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
t1=(total_flxhrs2 - total_flxhrs1)-summins;
}
else
{
inhrs1=nhrs1.inhrs(conloginmon);
othrs1= ohrs1.outhrs(conlogoutmon);
nnmins1= inmins1.mins(conloginmon);
onmins1 = outmins1.mouts(conlogoutmon);
total_hrs1= total_hrs1 + inhrs1;
total_hrs2= total_hrs2 + othrs1;
total_mins1 =total_mins1 + nnmins1;
total_mins2= total_mins2 + onmins1;
totmins=total_mins2+total_mins1;
summins=totmins/60;
a_flxhrs = total_hrs2 - total_hrs1;
totalh=(inhrs1+othrs1);
t1=totalh-summins;
}
System.out.println(" Tuesday ");
System.out.print(" Log_in: ");
Scanner sc3 = new Scanner(System.in);
String logintues = sc3.next();
String []arr3 = logintues.split(":");
String comlogintues = arr3[0]+arr3[1];
int conlogintues = Integer.parseInt(comlogintues);
nnmins1=inmins1.mins(conlogintues);
System.out.println(" Tuesday");
System.out.print(" Log_out: ");
Scanner sc4 = new Scanner(System.in);
String logouttues = sc4.next();
String []arr4 = logouttues.split(":");
String comlogouttues = arr4[0]+arr4[1];
int conlogouttues = Integer.parseInt(comlogouttues);
onmins1=outmins1.mouts(conlogouttues);
if(conlogintues>= 800 && conlogouttues<= 1200)
{
inhrs1 = nnhrs1.flxinhrs(conlogintues);
othrs1 =nnhrs1.flxinhrs(conlogouttues);
nnmins1 = nmins1.flxminsin(conlogintues);
onmins1 = omins1.flxminsout(conlogouttues);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
a_flxhrs = total_hrs2 - total_hrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
thm = (total_flxhrs2 - total_flxhrs1)-a_flxhrs;
t2=(thm-summins);
}
else if(conlogintues>= 1300 && conlogouttues <= 1700)
{
inhrs1= nnhrs1.flxinhrs(conlogintues);
othrs1 = nnhrs1.flxinhrs(conlogouttues);
nnmins1 = nmins1.flxminsin(conlogintues);
onmins1 = omins1.flxminsout(conlogouttues);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
t2=(total_flxhrs2 - total_flxhrs1)-summins;
}
else
{
inhrs1=nhrs1.inhrs(conlogintues);
othrs1= ohrs1.outhrs(conlogouttues);
nnmins1= inmins1.mins(conlogintues);
onmins1 = outmins1.mouts(conlogouttues);
total_hrs1= total_hrs1 + inhrs1;
total_hrs2= total_hrs2 + othrs1;
total_mins1 =total_mins1 + nnmins1;
total_mins2= total_mins2 + onmins1;
a_flxhrs = total_hrs2 - total_hrs1;
totmins=total_mins2+total_mins1;
summins=totmins/60;
totalh=(inhrs1+othrs1);
t2=totalh-summins;
}
System.out.println("(Wednesday)");
System.out.print(" Log_in: ");
Scanner sc5= new Scanner(System.in);
String loginwed = sc5.next();
String []arr5 = loginwed.split(":");
String comloginwed = arr5[0]+arr5[1];
int conloginwed = Integer.parseInt(comloginwed);
nnmins1=inmins1.mins(conloginwed);
System.out.println(" Wednesday ");
System.out.print( " Log_out: ");
Scanner sc6 = new Scanner(System.in);
String logoutwed = sc6.next();
String []arr6 = logoutwed.split(":");
String comlogoutwed = arr6[0]+arr6[1];
int conlogoutwed = Integer.parseInt(comlogoutwed);
onmins1=outmins1.mouts(conlogoutwed);
if(conloginwed>= 800 && conlogoutwed<= 1200)
{
inhrs1 = nnhrs1.flxinhrs(conloginwed);
othrs1 =nnhrs1.flxinhrs(conlogoutwed);
nnmins1 = nmins1.flxminsin(conloginwed);
onmins1 = omins1.flxminsout(conlogoutwed);
total_flxhrs1 = total_flxhrs1 +inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
a_flxhrs = total_hrs2 - total_hrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
thm = (total_flxhrs2 - total_flxhrs1)-a_flxhrs;
t3=(thm-summins);
}
else if(conloginwed>= 1300 && conlogoutwed<= 1700)
{
inhrs1= nnhrs1.flxinhrs(conloginwed);
othrs1 = nnhrs1.flxinhrs(conlogoutwed);
nnmins1 = nmins1.flxminsin(conloginwed);
onmins1 = omins1.flxminsout(conlogoutwed);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
t3=(total_flxhrs2 - total_flxhrs1)-summins;
}
else
{
inhrs1=nhrs1.inhrs(conloginwed);
othrs1= ohrs1.outhrs(conlogoutwed);
nnmins1= inmins1.mins(conloginwed);
onmins1 = outmins1.mouts(conlogoutwed);
total_hrs1= total_hrs1 + inhrs1;
total_hrs2= total_hrs2 + othrs1;
total_mins1 =total_mins1 + nnmins1;
total_mins2= total_mins2 + onmins1;
a_flxhrs = total_hrs2 - total_hrs1;
totmins=total_mins2+total_mins1;
summins=totmins/60;
totalh=(inhrs1+othrs1);
t3=totalh-summins;
}
System.out.println(" Thursday ");
System.out.print(" Log_in: ");
Scanner sc7= new Scanner(System.in);
String loginthur = sc7.next();
String []arr7 = loginthur.split(":");
String comloginthur = arr7[0]+arr7[1];
int conloginthur = Integer.parseInt(comloginthur);
nnmins1=inmins1.mins(conloginthur);
System.out.println(" Thursday ");
System.out.print(" Log_out: ");
Scanner sc8 = new Scanner(System.in);
String logoutthur = sc8.next();
String []arr8 = logoutthur.split(":");
String comlogoutthur = arr8[0]+arr8[1];
int conlogoutthur = Integer.parseInt(comlogoutthur);
onmins1=outmins1.mouts(conlogoutthur);
if(conloginthur>= 800 && conlogoutthur<= 1200)
{
inhrs1 = nnhrs1.flxinhrs(conloginthur);
othrs1 =nnhrs1.flxinhrs(conlogoutthur);
nnmins1 = nmins1.flxminsin(conloginthur);
onmins1 = omins1.flxminsout(conlogoutthur);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
a_flxhrs = total_hrs2 - total_hrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
thm = (total_flxhrs2 - total_flxhrs1)-a_flxhrs;
t4=(thm-summins);
}
else if(conloginthur>= 1300 && conlogoutthur<= 1700)
{
inhrs1= nnhrs1.flxinhrs(conloginthur);
othrs1 = nnhrs1.flxinhrs(conlogoutthur);
nnmins1 = nmins1.flxminsin(conloginthur);
onmins1 = omins1.flxminsout(conlogoutthur);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
t4=(total_flxhrs2 - total_flxhrs1)-summins;
}
else
{
inhrs1=nhrs1.inhrs(conloginthur);
othrs1= ohrs1.outhrs(conlogoutthur);
nnmins1= inmins1.mins(conloginthur);
onmins1 = outmins1.mouts(conlogoutthur);
total_hrs1= total_hrs1 + inhrs1;
total_hrs2= total_hrs2 + othrs1;
total_mins1 =total_mins1 + nnmins1;
total_mins2= total_mins2 + onmins1;
a_flxhrs = total_hrs2 - total_hrs1;
totmins=total_mins2+total_mins1;
summins=totmins/60;
totalh=(inhrs1+othrs1);
t4=totalh-summins;
}
System.out.println(" Friday ");
System.out.print(" Log_in: ");
Scanner sc9= new Scanner(System.in);
String loginfri = sc9.next();
String []arr9 = loginfri.split(":");
String comloginfri = arr9[0]+arr9[1];
int conloginfri = Integer.parseInt(comloginfri);
nnmins1=inmins1.mins(conloginfri);
System.out.println(" Friday");
System.out.print(" Log_out: ");
Scanner sc10 = new Scanner(System.in);
String logoutfri = sc10.next();
String []arr10 = logoutfri.split(":");
String comlogoutfri = arr10[0]+arr10[1];
int conlogoutfri = Integer.parseInt(comlogoutfri);
onmins1=outmins1.mouts(conlogoutfri);
if(conloginfri>= 800 && conlogoutfri<= 1200)
{
inhrs1 = nnhrs1.flxinhrs(conloginfri);
othrs1 =nnhrs1.flxinhrs(conlogoutfri);
nnmins1 = nmins1.flxminsin(conloginfri);
onmins1 = omins1.flxminsout(conlogoutfri);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
a_flxhrs = total_hrs2 - total_hrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
thm = (total_flxhrs2 - total_flxhrs1)-a_flxhrs;
t5=(thm-summins);
}
else if(conloginfri>= 1300 && conlogoutfri<= 1700)
{
inhrs1= nnhrs1.flxinhrs(conloginfri);
othrs1 = nnhrs1.flxinhrs(conlogoutfri);
nnmins1 = nmins1.flxminsin(conloginfri);
onmins1 = omins1.flxminsout(conlogoutfri);
total_flxhrs1 = total_flxhrs1 + inhrs1;
total_flxhrs2 = total_flxhrs2 + othrs1;
total_mins1 = total_mins1 + nnmins1;
total_mins2 = total_mins2 + onmins1;
totmins=total_mins1+total_mins2;
summins=totmins/60;
t5=(total_flxhrs2 - total_flxhrs1)-summins;
}
else
{
inhrs1=nhrs1.inhrs(conloginfri);
othrs1= ohrs1.outhrs(conlogoutfri);
nnmins1= inmins1.mins(conloginfri);
onmins1 = outmins1.mouts(conlogoutfri);
total_hrs1= total_hrs1 + inhrs1;
total_hrs2= total_hrs2 + othrs1;
total_mins1 =total_mins1 + nnmins1;
total_mins2= total_mins2 + onmins1;
a_flxhrs = total_hrs2 - total_hrs1;
totmins=total_mins2+total_mins1;
summins=totmins/60;
totalh=(inhrs1+othrs1);
t5=totalh-summins;
}
total=(total_hrs1+total_hrs2)+(((total_flxhrs2 - total_flxhrs1)-summins));
System.out.print("TOTAL HOURS : "+total);
salar=sal1.sals(rate, total);
System.out.println("\nTOTAL RATE : "+salar);
bw.write("CODE:"+arr[1]);
bw.write(","+loginmon);
bw.write(","+logoutmon);
bw.write(","+logintues);
bw.write(","+logouttues);
bw.write(","+loginwed);
bw.write(","+logoutwed);
bw.write(","+loginthur);
bw.write(","+logoutthur);
bw.write(","+loginfri);
bw.write(","+logoutfri+" ");
}
}
bw.close();
}
}
employee.txt
Juan_De_La_Cruz,A001,1
Miriam_Bismonte,A002,1
Gloria_Macapagal,A003,3
Manny_Pacquiao,A004,3
Jose_Rizal,A005,2
dtr.txt
CODE:A001,8:00,15:00,8:00,15:00,8:00,1:00,8:00,15:00,8:00,15:00 CODE:A001,8:00,13:00,8:00,16:00,7:00,16:00,8:00,16:00,8:00,16:00