fte,pte
Sun Oct 12 2025 12:14:19 GMT+0000 (Coordinated Universal Time)
Saved by @rcb
using System; // Base class class Employee { public string Name { get; set; } public int EmployeeID { get; set; } public double Salary { get; set; } public Employee(string name, int id) { Name = name; EmployeeID = id; } // Virtual method to be overridden in derived classes public virtual void CalculateSalary() { Salary = 0; } public void Display() { Console.WriteLine("Employee Name: " + Name); Console.WriteLine("Employee ID: " + EmployeeID); Console.WriteLine("Salary: " + Salary); Console.WriteLine("-----------------------------"); } } // Derived class: FullTimeEmployee class FullTimeEmployee : Employee { public double BasicSalary { get; set; } public int NumberOfDays { get; set; } public double HRA { get; set; } public double DA { get; set; } public FullTimeEmployee(string name, int id, double basic, int days, double hra, double da) : base(name, id) { BasicSalary = basic; NumberOfDays = days; HRA = hra; DA = da; } public override void CalculateSalary() { Salary = (BasicSalary * NumberOfDays) + HRA + DA; } } // Derived class: PartTimeEmployee class PartTimeEmployee : Employee { public double DailyWages { get; set; } public int NumberOfDays { get; set; } public PartTimeEmployee(string name, int id, double wages, int days) : base(name, id) { DailyWages = wages; NumberOfDays = days; } public override void CalculateSalary() { Salary = DailyWages * NumberOfDays; } } // Main Program class Program { static void Main() { // Create Full-Time Employee FullTimeEmployee fte = new FullTimeEmployee("Alice", 101, 1000, 22, 500, 300); fte.CalculateSalary(); fte.Display(); // Create Part-Time Employee PartTimeEmployee pte = new PartTimeEmployee("Bob", 102, 500, 15); pte.CalculateSalary(); pte.Display(); Console.ReadLine(); } }
Comments