//In the name of ALLAH
/*
SampleInput:
->Employee.txt
Hamidah Hassanuddin;12;3666.75;5
Auni Zahirah Luqman;10;4000.11;7
Helmi Hussain;5;2000.23;5
Amirul Haziq Mohd Yazid;8;1500.10;8
Maisara Abd Wahub;3;700.12;2
SampleOutputs:
->EmployeeUpdate.txt
Updated Salary
=============
Hamidah Hassanuddin 3850.0875
Auni Zahirah Luqman 4280.1177
Helmi Hussain 2100.2415
Amirul Haziq Mohd Yazid 1620.108
Maisara Abd Wahub 714.1224
->Junior.txt
Junior Employee
=============
Helmi Hussain 2000.23
Amirul Haziq Mohd Yazid 1500.1
Maisara Abd Wahub 700.12
->Senior.txt
Senior Employee
=============
Hamidah Hassanuddin 3666.75
Auni Zahirah Luqman 4000.11
*/
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
public class ABCCompany{
public static void main(String [] args){
try{
File input = new File("Employee.txt");
Scanner employee = new Scanner(input);
File output1 = new File("EmployeeUpdate.txt");
PrintWriter employeeUpdate = new PrintWriter(output1);
File output2 = new File("Junior.txt");
PrintWriter junior = new PrintWriter(output2);
File output3 = new File("Senior.txt");
PrintWriter senior = new PrintWriter(output3);
employeeUpdate.println("Updated Salary");
employeeUpdate.println("=============");
junior.println("Junior Employee");
junior.println("=============");
senior.println("Senior Employee");
senior.println("=============");
while (employee.hasNext()){
//Read data from Employee.txt
String inputString = employee.nextLine();
StringTokenizer st = new StringTokenizer(inputString,";");
String name = st.nextToken();
int serviceYear = Integer.parseInt(st.nextToken());
double currentSalary = Double.parseDouble(st.nextToken());
int percentSalary = Integer.parseInt(st.nextToken());
//Determine Status
String Status="";
if (serviceYear>=10)
Status = "Senior";
else
Status = "Junior";
//Store senior and junior
if (Status.equalsIgnoreCase("Senior"))
senior.println(name+" "+currentSalary);
else if (Status.equalsIgnoreCase("Junior"))
junior.println(name+" "+currentSalary);
//calculate new salary
double newSalary = currentSalary + (currentSalary*(percentSalary/100.0));
//store new salary
employeeUpdate.println(name+" "+newSalary);
}
//closeFile
employeeUpdate.close();
junior.close();
senior.close();
}
//catchException
catch(FileNotFoundException f){
System.out.println(f);
}
catch(IOException iox){
System.out.println(iox);
}
}
}