Answer to Question #325573 in C# for akashcc

Question #325573

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


1
Expert's answer
2022-04-07T17:36:22-0400
    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();
        }

    }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS