document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //In the name of ALLAH
  2. /*
  3. SampleInput:
  4. ->Employee.txt
  5. Hamidah Hassanuddin;12;3666.75;5
  6. Auni Zahirah Luqman;10;4000.11;7
  7. Helmi Hussain;5;2000.23;5
  8. Amirul Haziq Mohd Yazid;8;1500.10;8
  9. Maisara Abd Wahub;3;700.12;2
  10.  
  11. SampleOutputs:
  12. ->EmployeeUpdate.txt
  13. Updated Salary
  14. =============
  15. Hamidah Hassanuddin 3850.0875
  16. Auni Zahirah Luqman 4280.1177
  17. Helmi Hussain 2100.2415
  18. Amirul Haziq Mohd Yazid 1620.108
  19. Maisara Abd Wahub 714.1224
  20.  
  21. ->Junior.txt
  22. Junior Employee
  23. =============
  24. Helmi Hussain 2000.23
  25. Amirul Haziq Mohd Yazid 1500.1
  26. Maisara Abd Wahub 700.12
  27.  
  28. ->Senior.txt
  29. Senior Employee
  30. =============
  31. Hamidah Hassanuddin 3666.75
  32. Auni Zahirah Luqman 4000.11
  33. */
  34. import java.io.*;
  35. import java.util.*;
  36. import java.util.StringTokenizer;
  37. public class ABCCompany{
  38.     public static void main(String [] args){
  39.         try{
  40.             File input = new File("Employee.txt");
  41.             Scanner employee = new Scanner(input);
  42.             File output1 = new File("EmployeeUpdate.txt");
  43.             PrintWriter employeeUpdate = new PrintWriter(output1);
  44.             File output2 = new File("Junior.txt");
  45.             PrintWriter junior = new PrintWriter(output2);
  46.             File output3 = new File("Senior.txt");
  47.             PrintWriter senior = new PrintWriter(output3);
  48.             employeeUpdate.println("Updated Salary");
  49.             employeeUpdate.println("=============");
  50.             junior.println("Junior Employee");
  51.             junior.println("=============");
  52.             senior.println("Senior Employee");
  53.             senior.println("=============");
  54.            
  55.             while (employee.hasNext()){
  56.                 //Read data from Employee.txt
  57.                 String inputString = employee.nextLine();
  58.                 StringTokenizer st = new StringTokenizer(inputString,";");
  59.                 String name = st.nextToken();
  60.                 int serviceYear = Integer.parseInt(st.nextToken());
  61.                 double currentSalary = Double.parseDouble(st.nextToken());
  62.                 int percentSalary = Integer.parseInt(st.nextToken());
  63.                 //Determine Status
  64.                 String Status="";
  65.                 if (serviceYear>=10)
  66.                     Status = "Senior";
  67.                 else
  68.                     Status = "Junior";
  69.                 //Store senior and junior
  70.                 if (Status.equalsIgnoreCase("Senior"))
  71.                     senior.println(name+" "+currentSalary);
  72.                 else if (Status.equalsIgnoreCase("Junior"))
  73.                     junior.println(name+" "+currentSalary);
  74.                 //calculate new salary
  75.                 double newSalary = currentSalary + (currentSalary*(percentSalary/100.0));
  76.                 //store new salary
  77.                 employeeUpdate.println(name+" "+newSalary);
  78.             }
  79.             //closeFile
  80.             employeeUpdate.close();
  81.             junior.close();
  82.             senior.close();
  83.         }
  84.         //catchException
  85.         catch(FileNotFoundException f){
  86.             System.out.println(f);
  87.         }
  88.         catch(IOException iox){
  89.             System.out.println(iox);
  90.         }
  91.        
  92.     }
  93. }
');