Write a Python program employee.py that computes the cumulative salary of employees based on the length of their contract and their annual merit rate.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Employee class 

Write a Python program employee.py that computes the cumulative salary of employees based on the length of their contract and their annual merit rate.

 

Your program must include a class Employee with the following requirements:

Class attributes:

name: the name of the employee

position: the position of the employee

start_salary: the starting salary of the employee

annual_rate: the annual merit rate on the salary

contract_years: the number of years of salary

 

Class method:

get_cumulative_salary(): calculates and returns the cumulative salary of an employee based on the number of contract years. Round the cumulative salary to two digits after the decimal point.

Example: If start_salary = 100000, annual_rate = 5% and contract_years = 3:

Then the cumulative salary should be : 100000 + 105000 + 110250 = 315250

 

Outside of the class Employee, the program should have two functions:




Function name

Function description

Function input(s)

Function output(s) / return value(s)

print_employees()

Prints the employees' records in table format.

The column spacing is 20, left-aligned.

A list of employees objects

The employees records

main()

Prompts for the number of employees.

Prompts for the employee records comma-separated.

Calls the print_employees() function.

None

-

Starter code

class Employee:

        # define constructor here

        # todo

        # instance method

        def get_cumulative_salary(self):

        """

        This function calculates the cumulative salary after

        @param contract_years:

        @return: cumulated_salary

         """

        #todo

        pass

def print_employees(employees):

        """

        Prints employees records given a list of employee objects

        @param employees:

        @return:

        """

        #todo

         pass

def main():

         """

         Prompts for the number of employees. Reads the employee records comma-separated. Calls the       print_employees() function.

         @return:

         """

         number_of_employees = int(input("Enter the number of employees: "))

         employees = []

         # todo

         print_employees(employees)

main()

Sample Output

Enter the number of employees: 4

name, position, start salary, annual rate, contract years: Anita Borg,Lead developer,250000,2.6,4

name, position, start salary, annual rate, contract years: Frances Allen,Computer Scientist,280400,3,10

name, position, start salary, annual rate, contract years: Carol Shaw,Video Game Designer,184600,5.2,6

name, position, start salary, annual rate, contract years: Radia Perlman,Network Engineer,312850,1.92,1


Name                Position            Start salary        Annual rate         Cumulative salary   

Anita Borg          Lead developer      250000.0            2.6                 1039680.39          

Frances Allen       Computer Scientist  280400.0            3.0                 3214471.76          

Carol Shaw          Video Game Designer 184600.0            5.2                 1261968.68          

Radia Perlman       Network Engineer    312850.0            1.92                312850 

         

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY