Create an Employee class with the following specifications.
1. EmployeeName as string.
2. BasicSalary, HRA, DA, TAX, GrossSalary and NetSalary as double.
3. Calculate the HRA (15% of BasicSalary), DA (10% of BasicSalary), GrossSalary (BasicSalary + HRA + DA), Tax (8% of GrossSalary) and NetSalary (GrossSalary – Tax).
4. A Constructor to define the EmployeeName and BasicSalary.
5. A method CalculateNetPay to calculate the HRA, DA, Tax, GrossSalary and NetSalary values using the criteria mentioned in the Point 3.
6. A method Display to display the Salary structure
internal class Program
{
class Employee
{
public string EmployeeName { get; set; }
public double BasicSalary { get; set; }
public double HRA { get; set; }
public double DA { get; set; }
public double TAX { get; set; }
public double GrossSalary { get; set; }
public double NetSalary { get; set; }
public Employee(string name,double basicSalary)
{
EmployeeName = name;
BasicSalary = basicSalary;
}
public void CalculateNetPay()
{
HRA = BasicSalary * 0.15;
DA = BasicSalary * 0.1;
GrossSalary = BasicSalary + HRA + DA;
TAX = GrossSalary * 0.08;
NetSalary = GrossSalary - TAX;
}
public void Display()
{
CalculateNetPay();
Console.WriteLine($"Employee Name: {EmployeeName}\n" +
$"Basic Salary: {BasicSalary}\n" +
$"HRA: {HRA}\n" +
$"DA: {DA}\n"+
$"TAX: {TAX}\n"+
$"GrossSalary: {GrossSalary}\n"+
$"NetSalary: {NetSalary}\n");
}
}
static void Main(string[] args)
{
Employee employee = new Employee("Tom", 10000);
employee.Display();
Console.ReadKey();
}
}
Comments
Leave a comment