Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions