I need to solve this problem with using java I need main cla

I need to solve this problem with using java.

I need main class that can read employee.txt file with using below subclasses.

// employee.txt

John;007-K;12-31-2015;15.00
Victoria;101-G;08-15-2012;21.00
Brian;999-L;01-11-2014;17.00
Howardd;717-F;09-14-2013;34.00

import java.io.*;
import java.util.Scanner;


public class employee
{
   private String employee_name;
   private String employee_id;
   private String hiredate;

   public employee()
   {
       employee_name = \" \";
       employee_id = \" \";
       hiredate = \" \";

       }
   public employee (String employee_name, String employee_id, String hiredate )
   {
       setName (employee_name);
       setId (employee_id);
       setHireDate(hiredate);


       }


   public void setName(String nme)
   {
       employee_name = nme;

       }

   public void setId(String id)
       {
           employee_id = id;

       }


   public void setHireDate(String hd)
       {
               hiredate = hd;

       }
//------------------------------------------------------------------------------------------------------------------------//

public String getName()
{
       return employee_name;


       }


public String getId()
   {
           return employee_id ;


       }


   public String getHiredate()
{
       return hiredate;


       }


   }//end class employee

//------------------------------------------------------------------------------------------//

public class Production_Worker extends employee
{

   private int shift;
   private double hour_pay_rate;

   public Production_Worker (String employee_name, String employee_id, String hiredate , int shift , double hour_pay_rate)
   {
   super (employee_name,employee_id , hiredate);
   setShift (shift);
   setHourlypayrate(hour_pay_rate);
   }

   public int getShift()
   {
       return shift;
       }
       public double getHourlypayrate()
       {
       return hour_pay_rate;
   }

       public void setShift(int s)
       {
       shift = s;
   }

       public void setHourlypayrate(double pr)
       {
hour_pay_rate = pr;

}


}// end productionworker

Solution

import java.io.File;
import java.util.Scanner;

public class TestEmployee {
   public static void main(String[] args) {

       Scanner scanner = null;
       try {
           Production_Worker[] production_Workers = new Production_Worker[4];
           int count = 0;
           scanner = new Scanner(new File(\"employee.txt\"));
           while (scanner.hasNext()) {
               String line = scanner.nextLine();
               String[] lineArr = line.split(\";\");

               production_Workers[count++] = new Production_Worker(lineArr[0],
                       lineArr[1], lineArr[2], 1,
                       Double.parseDouble(lineArr[3]));

           }
           for (int i = 0; i < production_Workers.length; i++) {
               System.out.println(production_Workers[i]);
           }

       } catch (Exception e) {
           // TODO: handle exception
       }

   }
}

OUTPUT:
Production_Worker [shift=1, hour_pay_rate=15.0, getName()=John, getId()=007-K, getHiredate()=12-31-2015]
Production_Worker [shift=1, hour_pay_rate=21.0, getName()=Victoria, getId()=101-G, getHiredate()=08-15-2012]
Production_Worker [shift=1, hour_pay_rate=17.0, getName()=Brian, getId()=999-L, getHiredate()=01-11-2014]
Production_Worker [shift=1, hour_pay_rate=34.0, getName()=Howardd, getId()=717-F, getHiredate()=09-14-2013]

I need to solve this problem with using java. I need main class that can read employee.txt file with using below subclasses. // employee.txt John;007-K;12-31-20
I need to solve this problem with using java. I need main class that can read employee.txt file with using below subclasses. // employee.txt John;007-K;12-31-20
I need to solve this problem with using java. I need main class that can read employee.txt file with using below subclasses. // employee.txt John;007-K;12-31-20

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site