Python Practice › OOP Programs › Program 39

Manager with bonus

EasyOOP Programs · 39 of 48

Create Manager (inherits Employee) with department and bonus, and a method for total compensation.

Advertisement
Output
Ravi QA 1350000

Approach

  1. Total = salary + bonus.

Solution

Python
class Employee:    def __init__(self, name, salary):        self.name, self.salary = name, salary class Manager(Employee):    def __init__(self, name, salary, department, bonus):        super().__init__(name, salary)        self.department, self.bonus = department, bonus     def total(self):        return self.salary + self.bonus m = Manager("Ravi", 1200000, "QA", 150000)print(m.name, m.department, m.total())
Output
Ravi QA 1350000

Learn the concept

New to this topic? Read the lesson, then come back.

More oop programs

← All 48 OOP Programs

Leave a Comment