Question: Create a Python project Retirement. Add a Python file employee.py to this project. Define a class Employee in this file. In this class, create three

Create a Python project Retirement. Add a Python file employee.py to this project. Define a class Employee in this file. In this class, create three publicly accessible instance variables to store employees name, salary, and years of service. Define the following methods:

A __init__ method that accepts the employees name, salary and years of service as arguments. Write statements in __init__ to store them in instance variables.

A pension method to calculate the monthly pension payout the employee will receive in retirement: monthly pension payout = salary * years of service * 0.0015. No arguments need to be passed to this method when this method is called. It uses data stored in the instance variables to calculate monthly pension payout. This method returns the monthly pension payout.

The following class diagram shows the design of this class:

Employee

+name: String

+salary: Float

+yr_service: Float

+create(e_name:String, e_salary:Float, e_yr_service: Float)

+pension(): Float

Add a file retirement_main.py to this project. This is the main module. Write code to ask the user to enter name, salary and years of service of two employees. Create two instances of Employee. Call the pension method of these objects to calculate pensions. Display the pensions.

The following shows a sample test run:

Enter name: Joe Chen

Enter salary: 80000

Enter years of service: 30

Monthly pension payout: 3600.0

Enter name: Jean Park

Enter salary: 60000

Enter years of service: 25

Monthly pension payout: 2250.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!