title: Exercise: Extend PayrollSystem with HourlyEmployee and CommissionEmployee/ Studying Python
body: <pre><code>class PayrollSystem:
      def calculate_payroll(self,employees):
          for employee in employees:
              print('Employee Payroll')
              print('================')
              print(f'Payroll for: {employee.id} - {employee.name}')
              print(f'- Check amount: {employee.calculate_salary()}')
              print('')
  
  class Employee:
      def __init__(self, id, name):
          self.id=id
          self.name=name
      def ask_name(self):
          try:
              self.name=str(input(&quot;Please enter employee name:&quot;))
          except:
              self.name=''
  
  class SalaryEmployee(Employee):
      def __init__(self, id, name, monthly_salary):
          super().__init__(id, name)
          self.salary='M'
          self.monthly_salary=int(monthly_salary)
      def ask_salary(self):
          try:
              self.monthly_salary=int(input(&quot;Please enter monthly salary:&quot;))
          except:
              self.monthly_salary=0
      def calculate_salary(self):
          return self.monthly_salary
  
  class HourlyEmployee (Employee):
      def __init__(self, id, name,hour_rate, hour_worked):
          super().__init__(id, name)
          super().__init__(id, name)
          self.hour_rate=int(hour_rate)
          self.hour_worked=int(hour_worked)
      def ask_salary(self):
          try:
              self.hour_worked=int(input(&quot;Please enter hours worked: &quot;))
              self.hour_rate=int(input(&quot;Please enter hour rate: &quot;))
          except:                            
              self.hour_worked=0
              self.hour_rate=0
      def calculate_salary(self):
          self.monthly_salary=self.hour_worked*self.hour_rate
  
  class CommissionEmployee (SalaryEmployee):
      def __init__(self, id, name, monthly_salary,commission):
          super().__init__(id, name, monthly_salary)
          self.commission=int(commission)
      def ask_salary(self):
          try:
              self.commission=int(input(&quot;Please enter commission: &quot;))
          except:                            
              self.commission=0
      def calculate_salary(self):
          self.monthly_salary=(self.monthly_salary+self.commission)
  employees=[]
  
  id=1
  while True:
      salarytype=int(input(&quot;Please enter salary type:\n(1) monthly\n(2) hourly\n(3) commission\n(0) Quit\n&quot;))
      if salarytype==1:
          employee=SalaryEmployee(id,'',0)
          SalaryEmployee.ask_name(employee)
          SalaryEmployee.ask_salary(employee)
          employees.append(employee)
          id+=1
      elif salarytype==2:
          employee=HourlyEmployee(id,'',0,0)
          HourlyEmployee.ask_name(employee)
          HourlyEmployee.ask_salary(employee)
          employees.append(employee)
          id+=1
      elif salarytype==3:
          employee=CommissionEmployee(id,'',0,0)
          CommissionEmployee.ask_name(employee)
          CommissionEmployee.ask_salary(employee)
          employees.append(employee)
          id+=1
      elif salarytype==0:
          break
      else:
          print(&quot;Incorrect selection.&quot;)
  payroll_system=PayrollSystem()
  payroll_system.calculate_payroll(employees)
  </code></pre>
  <p>Here is my code. The expected out when I input number 2 and then input 0, it showed
  &quot;Payroll for: 1 - J</p>
  <ul>
  <li>Check amount: None&quot;
  It should be the multiply between hour_rate and hour_worked. Please help me, how can I do the formula to export the result? Thank you</li>
  </ul>