Employee Class

The task is to implement a class Employee that represents the data and operations of an employee in a company. An Employee has four attributes:
  • name: a string that represents the name of the employee.
  • id: a string that represents the employee id.
  • department: a string that represents the department of the employee.
  • salary: a float that represents the monthly salary of the employee.
The Employee class should have the following methods:
  • get_details(): Returns a string representation of an Employee. This string should contain the name, id, and department of the Employee (see the example).
  • calculate_annual_salary(): Returns a float that is the annual salary of the Employee. The annual salary is calculated as the monthly salary multiplied by 12.
Input
Output
john = Employee('John Doe', 'JD01', 'Engineering', 5000.0); print(john.get_details()); print(john.calculate_annual_salary()); john.department = 'Management'; john.salary = 7000; print(john.get_details()); print(john.calculate_annual_salary())
Name: John Doe, ID: JD01, Department: Engineering 60000.0 Name: John Doe, ID: JD01, Department: Management 84000.0
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue