Good day! I was writing a code that will compute the salary of each employee on our school depending on their position using a FileReader(File Handling). I only managed to do this code and don't know how to start again

``````import java.io.*;
import static java.lang.System.out;

{

static File file = new File("Employee.txt");
static String[][] Employee;
static int numOfEmployee;
static int numRow;

public static int UserChoice()throws Exception
{

out.print("[2] Edit Employee\n");
out.print("[3] Delete Employee\n");
out.print("[4] Search Employee\n");
out.print("[5] View All Employees\n");
out.print("[6] Exit\n");

return choice;
}
public static String[] EnterValues()throws Exception
{
int random = (int)( Math.random() * 20000);
String[] info = new String[7];
info[0] = Integer.toString(random);
out.print("Enter Employee's First Name:");
out.print("Enter Employee's Middle Name:");
out.print("Enter Employee's Last Name:");
out.print("Enter Employee's Age:");
out.print("Enter Employee Position:");

return info;
}

{
FileWriter fw = new FileWriter(file,true);
for ( int x =0; x < info.length; x++)
{
if( x == info.length - 1)
fw.write(info[x] + "\r\n");
else
fw.write(info[x] + ",");

}
fw.close();

}
//***************************SEARCHING*************************************

public static Boolean SearchEmployee()throws Exception
{
out.print("Enter Employee ID:");
boolean result = false;
int x;
for ( x=0; x< numOfEmployee;x++)
{
if(id.equals(Employee[x][0]))
{
out.println("Search Result:");
out.println("Employee Name: " + Employee[x][1] + " " + Employee[x][2] + " " + Employee[x][3]);
out.println("Employee Age: " + Employee[x][4]);
out.println("Position:" + Employee[x][6]);
result = true;
break;
}
}
numRow = x;
return result;
}
//*************************END OF SEARCHING**************************
public static void EditEmployee(int row) throws Exception
{
out.println("Edit Employee:");
out.println("Enter New Employee's First Name:");
out.println("Enter New Employee's Middle Name:");
out.println("Enter New Employee's Last Name:");
out.println("Enter New Employee's Age:");
out.println("Enter New Employee's Position:");
SaveChanges();
}
public static void DeleteEmployee(int row) throws Exception
{
out.println("Delete Employee");
for ( int col = 0; col < 7; col++)
{
Employee[row][col]=null;
}
SaveChanges();
}

public static void SaveChanges()throws Exception
{
FileOutputStream fos = new FileOutputStream(file);
PrintStream ps = new PrintStream(fos);
for ( int x = 0; x < numOfEmployee; x++)
{
for ( int y = 0; y < 7; y++)
{
if(Employee[x][y] != null)
ps.print(Employee[x][y] + ",");
if( y == 6 && Employee[x][y] != null)
ps.println();
}
}
ps.close();
}

public static void  LoadEmployee() throws Exception
{
FileInputStream fis = new FileInputStream(file);
int row=0; String all ="";
{
row++;
}
numOfEmployee = row;
String[] temp = all.split(",");
Employee = new String[row][7];
int ctr=0;
for ( int x=0; x<row; x++)
{
for (int y=0; y<6; y++)
{
Employee[x][y] = temp[y+ctr];
}
}
ctr+=6;
}

public static void DisplayAll(int row)throws Exception
{
out.println("List of Employee("+numOfEmployee+")records");
for (int x=0; x < row ;x++)
{
for ( int y =0; y< 6; y++)
{
out.print(Employee[x][y] + "\t");
}
out.println();
}
}
public static void main(String[] args) throws Exception
{
{
int choice = UserChoice();// display Menu
if ( choice == 1 )
{
}
else if ( choice == 2)
{
if(SearchEmployee())
{
out.print("Do You Really Want to Modify This Record? (Y/N):");
if(rep == 'y' || rep == 'Y')
{
EditEmployee(numRow);
}
else
{
out.println("No Record found!");
}
}
}
else if ( choice == 3)
{
if(SearchEmployee())
{
out.print("Do you really want to delete this record?(Y/N)");
if ( rep == 'y' || rep == 'Y')
{
DeleteEmployee(numRow);
}
else
{
out.println("No Record Found!");
}
}
}
else if ( choice == 4)
{
if (SearchEmployee())
{
out.println("No Record Found!");
}

}
else if (choice == 5)
{
DisplayAll(numOfEmployee);
}
else if ( choice == 6)
{
break;
}

{
out.println("Invalid Input!");
}
}
}
}``````

can someone give me an idea of what should I do?

Probably not - you haven't really asked a question.

## All 2 Replies

Probably not - you haven't really asked a question.

Write down each of the tasks that you require.
Write down each STEP of the tasks that you require.