EmployeeClass

PHOTO EMBED

Wed Oct 29 2025 17:16:13 GMT+0000 (Coordinated Universal Time)

Saved by @vplab

class Employee
{
    public string name;
    public int empId;
    public double salary;

    public virtual void calculateSalary()
    {
        salary = 0;
    }

    public void displayEmployeeDetails()
    {
        System.Console.WriteLine("Employee Name: " + name);
        System.Console.WriteLine("Employee ID: " + empId);
        System.Console.WriteLine("Employee Salary: " + salary);
    }
}

class FullTimeEmployee : Employee
{
    public double HRA,DRA,basicSalary;
    public int days;
    public override void calculateSalary()
    {
        salary=(basicSalary*days)+HRA+DRA;
    }
}

class PartTimeEmployee : Employee
{
    public double dailyWages;
    public int numberOfDays;

    public override void calculateSalary()
    {
        salary = dailyWages * numberOfDays;
    }
}

class Program
{
    static void Main(string[] args)
    {
        FullTimeEmployee f=new FullTimeEmployee();
        f.name="John Doe";
        f.empId=101;
        f.basicSalary=500;
        f.HRA=2000;
        f.DRA=1500;
        f.days=22;
        f.calculateSalary();
        f.displayEmployeeDetails();
        PartTimeEmployee p=new PartTimeEmployee();
        p.name="Jane Smith";
        p.empId=102;
        p.dailyWages=300;
        p.numberOfDays=15;
        p.calculateSalary();
        p.displayEmployeeDetails();

    }
}
content_copyCOPY