I have to write a program which keeps information of 10 employees(Employee Number, Surname, First Name, Position, Salary, Percentage Attendance, and Number of Casual Leaves, and Number of Sick Leaves remaining) in a single string (employeeDetailsStrings) separated by a #
that is in the format
E101#John#Wills#Software Engineer#40000#78#25#12.
The system should allow the user to search for an employee based on either his Surname or Employee Number, and then display all the details corresponding to that employee. The system should give and error message in case the employee is not found. The program uses an array to hold the details of the 10 employees.
Here is what I have come up so far:
import java.util.*;
public class labsheets {
public static void main(String args[]){
Scanner sc= new Scanner(System.in);
String[] empDetString= new String[10];
String input;
int i;
System.out.println("Enter emp details: ");
for (i=0; i<empDetString.length; i++){
empDetString[i]= sc.nextLine();
empDetString[i].split("#");
}
}
I don't know how to split each of these 10 arrays of employee details separated by a hashtag as apparently my approach is wrong. The output should be as follows after a match has been found through either the employee number or surname.
Output:
Employee Number is : E101
Surname : Wills
First Name : John
Position : Software Engineer
Salary : 40000
% Attendance : 78
Casual Leaves left : 25
Sick Leaves left : 12