-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmployee Class1.cs
83 lines (72 loc) · 2.31 KB
/
Employee Class1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Module2_PRA
{
class Employee
{
protected int employeeId;
protected string fullName;
protected float salary;
protected bool taxDeducted;
public Employee(int employeeId, string fullName, float salary, bool taxDeducted)
{
this.employeeId = employeeId;
this.fullName = fullName;
this.salary = salary;
this.taxDeducted = taxDeducted;
}
public Employee(int employeeId, string fullName, float salary)
{
this.employeeId = employeeId;
this.fullName = fullName;
this.salary = salary;
this.taxDeducted = true;
}
public float GetNetSalary()
{
double netsalary;
if (this.taxDeducted == true)
{
netsalary = salary * 0.8;
}
else
{
netsalary = salary;
}
return Convert.ToSingle(netsalary);
}
public void printInformation()
{
Console.WriteLine(employeeId + "," + "earns" + GetNetSalary() + "per month");
}
}
class WeeklyEmployee: Employee
{
public WeeklyEmployee(int employeeId, string fullName, float salary, bool taxDeducted)
: base(employeeId, fullName, salary, taxDeducted) { }
public WeeklyEmployee(int employeeId, string fullName, float salary)
: base(employeeId, fullName, salary) { }
public new float GetNetSalary()
{
double netWeeklySalary;
netWeeklySalary = (salary * 12) / 52;
double netsalaryweekly;
if (this.taxDeducted == true)
{
netsalaryweekly = netWeeklySalary * 0.8;
}
else
{
netsalaryweekly = netWeeklySalary;
}
return Convert.ToSingle(netsalaryweekly);
}
public new void printInformation()
{
Console.WriteLine(employeeId + "," + fullName + "earns" + GetNetSalary() + "per week");
}
}
}