Create a C# Application. Create a class object called “Employee” which includes
ID: 3783573 • Letter: C
Question
Create a C# Application. Create a class object called “Employee” which includes the following private variables:
firstN
lastN
idNum
wage: holds how much the person makes per hour
weekHrsWkd: holds how many total hours the person worked each week
regHrsAmt: initialize to a fixed amount of 40 using constructor.
regPay
otPay
After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:
constructor
properties
CalcPay(): Calculate the regular pay and overtime pay.
Create an “EmployeeDemo” class. In the main function, the program should ask the user the number of employee in the company and create a 2-dimensional dynamic array (number of employee by 4 weeks). Then, the program should ask user to enter each employee’s information and the amount of hours they worked weekly.
The program shows a menu with employee name for user to choose which employee to display the following information:
How much the person totally made
How much of paycheck is regular pay
How much of paycheck is overtime pay
Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EmployeeIndexer
{
class Program
{
static void Main(string[] args)
{
Employee emp=new Employee();
EmployeeDemo demo=new EmployeeDemo();
}
class EmployeeDemo
{
int num,weekHrswkd;
Console.WriteLine(" number of employee:");
num=Int32.Parse(Console.ReadLine());
Employee emp=new Employee();
Console.WriteLine(" hours they worked weekly:");
weekhrswkd=Int32.Parse(Console.ReadLine());
calcpay pay=new calcpay();
}
class calcpay
{
int regpay,otpay;
regpay=regHrsamt*weekHrswkd;
otpay=regpay*1.5*otHrswkd;
}
class Employee
{
Employee[] emp=new Employee[10];
int index=0;
public void AddEmployee()
{
string firstN,lastN;
int idNum,wage,regHrsAmt,regpay,otpay;
Console.WriteLine("Enter the details");
Console.WriteLine("first name:");
firstN=Console.ReadLine();
Console.WriteLine("last name:");
lastN=Console.ReadLine();
Console.WriteLine("EMPLOYEE NUMBER:");
idNum=Int32.Parse(Console.ReadLine());
Console.WriteLine("SALARY:");
Wage=Int32.Parse(Console.ReadLine());
Console.WriteLine("hours worked for a week:");
regHrsAmt=Int32.Parse(Console.ReadLine());
Console.WriteLine(" regular salary:");
emp[index]=new Employee(firstN,lastN,idNum,wage,weekHrswkd,reghrsAmt,regpay,otpay);
index++;
}
}
}