C Create a Worker classes that are derived from Employee cla

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)

Solution

#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;

}

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site