employeeinfotxt end employeeinfotxt C You have to create tw

********employeeinfo.txt********

******end - employeeinfo.txt*********

C#

You have to create two classes. The first class “Employee” which included:

The private variables:

·         first name

·         last name

·         id number (Format: A#####)

·         Wage

·         hoursWorked

The hoursWorked variable holds how many total hours the person worked. When the hoursWorked is over 40 hours, it will be considered as over time. Wage holds how much the person makes per hour. After passing the 40 hours, they get 1.5 x the wage for each additional hour worked.

The functions:

·         Constructors

·         Properties

·         GetGrossPay: calculate the gross pay for the employee (Be careful with the over time)

The second class will be “EmployeeDemo” class with the main function. In the main function, Read the data from the “employeeinfo.txt” file and save the data in the array of (Employee) objects. In the file, the first number is the total number of employees and each employee’s information.

After import the data, display a menu for user to choose:

1.      Display all employees

2.      Add New employee

3.      Quit the program (save the information to “employeeinfo.txt” file)

Display Example:

FirstN               LastN               ID                     GrossPay

John                 Wu                   A00001            $906.25

Bob                  Ho                    A00002            $420

Jenny               Pena                A00003            $561.88

Sam                 Sosa                 A00004            $420

Linda                Jordan             A00005            $1019.88

Solution

*****************************************EmployeeDemo**************************************

using System;
using System.IO;
class EmployeeDemo
{
static void Main(string[] args)
{
  
string[] lines = System.IO.File.ReadAllLines(@\"EmployeeInfo.txt\");



  
Employee[] eArr=new Employee[lines.Length];
string[] arr=new string[lines.Length];
  
for(int k=0;k<lines.Length;k++){
for(int i=0;i<lines.Length;i++){
string[] words = lines[i].Split(\' \');
arr[i]=words[i];
}
  
for(int i=0;i<lines.Length;i++){
eArr[i].setData(arr[0],arr[1],arr[2],arr[3],arr[4]);
}
}

foreach (string line in lines)
{
// Use a tab to indent each line of the file.
Console.WriteLine(\"\\t\" + line);
}
  
}
  
}

*************************************Employee****************************************


using System.IO;
using System;

class Employee
{
string fname;
string lname,id;
float wage,hrsw,pay;
public Employee(){
fname=\"\";
lname=\"\";
id=\"\";
wage=0;
hrsw=0;
pay=0;
}
  
  
public void setData(string a,string b,string c,string d,string e){
fname=a;
lname=b;
id=c;
wage=float.Parse(d);
hrsw=float.Parse(e);
}
  
public float getGrossPay(){
if(hrsw>0 && hrsw<=40){
pay=hrsw*wage;
}
else if(hrsw>40){
pay=40*wage + (hrsw-40)*(float)1.5;
}
return pay;
}
  
  
  
}

****************************output file*************************************

Chris Wade A14225 30 30
Billy Peters A34685 30 45
Jill Bane A14253 30 40
Tommy Johnson A14526 30 48
Peter James A31245 30 32

********employeeinfo.txt******** ******end - employeeinfo.txt********* C# You have to create two classes. The first class “Employee” which included: The private
********employeeinfo.txt******** ******end - employeeinfo.txt********* C# You have to create two classes. The first class “Employee” which included: The private
********employeeinfo.txt******** ******end - employeeinfo.txt********* C# You have to create two classes. The first class “Employee” which included: The private

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site