Question

# Write a Java program that reads employee information from the file “employee.txt” then the program will...

Write a Java program that reads employee information from the file “employee.txt” then the program will display his/her information on the screen.
The file contains the Employee’s Name, age,join date, quit date, and salary.

• For each year the employee is in the company,10 days of sick leave are allowed. So, if an employee is in the company for two years, 20 days of sick leave are allowed.

• For each year the employee is in the company, one-month salary is allowed. Therefore, if an employee is in a company for 3 years, his/her end of service will be the salary of 3 month.

• The employee is eligible for retirement at the age of 60.

The program shall calculate and display on the screen the employee’s: (name,age,join date, quit date, salary, leave days, end of service, and retirement eligibility).

Sample input/output

 “employee.txt” Output Shamma 38 2010 2020 15,000.0 Employee Name:Shamma Age: 38Y Join date: 2010 Quit date: 2020 Salary: 15,000.0 Sick Leave days: 100 End of service: 150,000.0 You are not eligible for retirement

``````import java.io.File;
import java.io.FileNotFoundException;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;

public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(new File("employee.txt"));
System.out.println("Employee Name: " + sc.nextLine().trim());
int age = Integer.parseInt(sc.nextLine().trim());
System.out.println("Age: " + age + "Y");
int join = Integer.parseInt(sc.nextLine().trim());
System.out.println("Join Date: " + join);
int quit = Integer.parseInt(sc.nextLine().trim());
System.out.println("Quit Date: " + quit);
String sal = sc.nextLine().trim();
float salary = Float.parseFloat(sal.replaceAll("[^\\d.]+", ""));
System.out.println("Salary: " + sal);
System.out.println("Sick Leave days: " + ((quit - join) * 10));
float eos=salary*(quit-join);
NumberFormat formatter=NumberFormat.getCurrencyInstance(Locale.US);
System.out.println("End of service: " + formatter.format(eos).substring(1));
if (age >= 60)
System.out.println("You are eligible for retirement");
else
System.out.println("You are not eligible for retirement");
sc.close();
}
}
``````

#### Earn Coins

Coins can be redeemed for fabulous gifts.