Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# Create a “Worker” classes that are derived from Employee class. In Worker cla

ID: 3931342 • Letter: C

Question

C#

Create a “Worker” classes that are derived from Employee class. In Worker class, it has one field, yearWorked. It includes constructor(s) and properties. It also includes two functions: first, calcYearWorked function, it takes one parameter (currentyear) and calculates the number of year the worker has been working (current year–yearStartedWked) and save it in the yearWorked variable. Second, the calcCurSalary function that calculate the current year salary by overriding the base class function using initial salary with 3% yearly increment.

(Employee class has been previously created)

Explanation / Answer

#include <stdio.h>

struct employee{

    char    name[30];

    int     empId;

    float   salary;

};

int main()

{

    /*declare structure variable*/

    struct employee emp;

    

    /*read employee details*/

    printf(" Enter details : ");

    printf("Name ?:");          gets(emp.name);

    printf("ID ?:");            scanf("%d",&emp.empId);

    printf("Salary ?:");        scanf("%f",&emp.salary);

    

    /*print employee details*/

    printf(" Entered detail is:");

    printf("Name: %s"   ,emp.name);

    printf("Id: %d"     ,emp.empId);

    printf("Salary: %f ",emp.salary);

    return 0;

}