3
我应该编写一个名为Employee的类,它包含名称,工资和服务年限的数据。它计算员工在退休时将收到的每月养老金支出,并显示Employee对象的三个实例变量。它还调用Employee对象的养老金方法来计算此员工的每月养老金支出并显示它。运行python程序后没有输出
运行我的程序后,我没有得到任何输出,这是特定的问题。
我应该得到这样的输出:
Name: Joe Chen
Salary: 80000
Years of service: 30
Monthly pension payout: 3600.0
Process finished with exit code 0
下面是完整的代码。
class Employee:
# init method implementation
def __init__(self, EmpName, EmpSalary, EmpYos):
self.EmpName = EmpName
self.EmpSalary = EmpSalary
self.EmpYos = EmpYos
def displayEmployeeDetails(self):
print "\nName ", self.EmpName,
# defines the salary details
def displaySalary(self):
print "\nSalary", self.EmpSalary
# defines the years of service
def displayYoservice(self):
print "\nYears of Service", self.EmpYos
# defines pension
def MonthlypensionPayout(self):
print "\nMonthly Pension Payout:", self.EmpSalary * self.EmpYos * 0.0015
def main():
# creates instance for employee 1
Emplo1 = Employee("Joe Chen", 80000, 30)
# creates instance for employee 2
Emplo2 = Employee("Jean park", 60000, 25)
# Function calls
Emplo1.displayEmployeeDetails()
Emplo1.displaySalary()
Emplo1.displayYoservice()
Emplo1.MonthlypensionPayout()
# function calls
Emplo2.displayEmployeeDetails()
Emplo2.displaySalary()
Emplo2.displayYoservice()
Emplo2.MonthlypensionPayout()
main()
你的Python版本是什么? – Exprator
删除def main:和main() – Exprator
@Exprator我认为Python的版本是2,因为他没有括号打印。 –