0
Create an employee class with the following attributes:
- number
- name
- salBruto
- salLiquido
- taxaIRS
- fees
And the following methods:
- calcIRS()
- calcSS()
- calcSalLiquido()
Taking into account the following conditions:
- If gross wage >= 2000.00, irs rate = 25%
- If gross wage >= 1000.00 && < 2000.00, irs rate = 20%
- If gross wage < 1000.00, irs rate = 17.5%
- SS = fixed rate of 11%
Create an object from this class, read a typed gross wage and present on screen all desired calculations (Gross, IRS, SS and Net).
class empregado:
def __init__(self, numero, nome, salBruto, salLiquido, taxaIRS, taxas):
self.numero = numero
self.nome = nome
self.salBruto = salBruto
self.salLiquido = salLiquido
self.taxaIRS = taxaIRS
self.taxas = taxas
def calcIRS(self):
if (self.salBruto >= 2000):
self.taxaIRS = self.salBruto * 0.25
elif ((self.salBruto >= 1000) and (self.salBruto < 2000)):
self.taxaIRS = self.salBruto * 0.20
elif (self.salBruto < 1000):
self.taxaIRS = self.salBruto * 0.175
return self.taxaIRS
def calcSS(self):
self.taxas = self.salBruto * 0.11
return self.taxas
def calcSalLiquido(self):
self.salLiquido = self.salBruto - (self.taxaIRS + self.taxas)
return self.salLiquido
numero = int(input('Digite o numero do empregado: '))
nome = input('Digite o nome do empregado: ')
salBruto = float(input('Digite o seu salário bruto: '))
taxaIRS = empregado.calcIRS(self=salBruto)
taxas = empregado.calcSS(self=salBruto)
salLiquido = empregado.calcSalLiquido(self=salBruto)
empregado1 = empregado(numero, nome, salBruto, salLiquido, taxaIRS, taxas)
print('Dados Salário do empregado', empregado1.nome, ', nº ', empregado1.numero, ': ')
print('Salário Bruto: ', empregado1.salBruto)
print('Valor do IRS: ', empregado1.taxaIRS())
print('Valor da SS: ', empregado1.taxas())
print('Salário Líquido: ', empregado1.salLiquido())
This error appears when I run the program and comes to the part of calculating the IRS "'float 'Object has no attribute 'salBruto'".
Could someone please help me!!
I did what Voce told me but when I create the employee instance using a constructor that receives the input data gives error because the other 3 arguments "salLiquido, taxaIRS and taxes" because I’m only using the first 3
– Sanntozzz
You need to change your original constructor to receive only 3 parameters.
– Emerson Pardo