Question

In: Computer Science

Using UML, design a class that allows you to store and print employee information: name, id,...

Using UML, design a class that allows you to store and print employee information: name, id, and hourly_salary. Include the appropriate mutator and accessor methods.

Write the code to create the class.

Write a test program that instantiates an employee object. After the object is created write the code to give the employee a 3% raise.

(IN PYTHON)

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 
 

=====================================================================

class Employee():

    def __init__(self, name, id, hourly_salary):
        self.__name = name
        self.__id = id
        self.__hourly_salary = hourly_salary

    def getName(self): return self.__name

    def getID(self): return self.__id

    def getHourlySalary(self): return self.__hourly_salary

    def incrementSalary(self, percentage):
        self.__hourly_salary += self.__hourly_salary * percentage / 100

    def __str__(self):
        return 'Employee Name: {}, Id: {}, Hourly Salary ${:.2f}'.format(self.__name, self.__id,
                                                                          self.__hourly_salary)


def main():
    emp = Employee('John Doe', 123, 30)
    print(emp)
    print('Incrementing salary by 3% percentage')
    emp.incrementSalary(3)
    print(emp)
main()

====================================================================


Related Solutions

java/netbeans 1.Design an abstract class Employee that stores: employee name, unique auto-generated id, hire year. Implement...
java/netbeans 1.Design an abstract class Employee that stores: employee name, unique auto-generated id, hire year. Implement any necessary methods in addition to: a.The toString and equals methods. The equals method should NOT compare the id. b.The copy constructor (should copy the same id too) c.An abstract method float getWeeklyCheckAmount() d.Implement the appropriate interface to be able to sort employee names in alphabetical order. Subclasses should NOT be allowed to override this implementation. 2.Design an abstract class HourlyWorker that extends Employee...
Develop an algorithm to implement an employee list with employee ID ,name designation and department using...
Develop an algorithm to implement an employee list with employee ID ,name designation and department using link list and perform the following operation on the list i)add employee details based on department ii)remove employee details iv)count the number of employee in each department
Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
List department name, employee id, and employee name for all employees in department name order. Repeat...
List department name, employee id, and employee name for all employees in department name order. Repeat for department #10 only. List the course ID, course name, section, instructor name, day, time, and room for all course sections. List the course ID, course name, section, student ID, and student name for CRN 1003. Display the list in ascending order of student last and first names. DROP TABLE registration; DROP TABLE sections; DROP TABLE courses; DROP TABLE students; DROP TABLE instructors; CREATE...
Implement an Employee class that includes data fields to hold the Employee’s ID number, first name,...
Implement an Employee class that includes data fields to hold the Employee’s ID number, first name, last name, and hourly pay rate (use of string datatype is not allowed). Create an array of five Employee objects. Input the data in the employee array. Write a searchById() function, that ask the user to enter an employee id, if its present, your program should display the employee record, if it isn’t there, simply print the message ”Employee with this ID doesn’t exist”....
The system will accept the employee ID, the employee name and his/her gross salary.
The system will accept the employee ID, the employee name and his/her gross salary.Based on the gross salary provided, if it is equal to or greater than OMR 2500, the system should apply a tax rate of 6% when calculating the income tax otherwise a tax rate of 4% should be applied when calculating.calculate the income tax and the net salary,If (gross salary > = 2500)          Tax rate = 6%Else     Tax rate = 4%Income tax = Net salary = 
Using C#: Write a class named Employee that has the following properties: Name - The Name...
Using C#: Write a class named Employee that has the following properties: Name - The Name property holds the employee's name IdNumber - The IdNumber property holds the employee's ID number Department - The Department property holds the name of the department in which the employee works Position - The Position property holds the employee's job title The class should have the following overloaded constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate...
Exercise: Three UML class diagrams are given below. Class Employee is the superclass and the other...
Exercise: Three UML class diagrams are given below. Class Employee is the superclass and the other two classes, Manager and Programmer, are subclasses of Employee. Employee - name: String # salary: double + Employee( ) + setEmployee( String, double ): void + getName( ): String + getSalary( ): double + print( ): void Manager Programmer - numEmps: int - language: String + Manager( ) + setManager( String, double, int ): void + getNumEmps( ): int + getSalary( ): double +...
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-
Consider the following relational database schema:             employee(employee-name, employee-id, street, e-city)             works(employee-id, company-id, salary)             company(company-name, company-id, c-city)             manages(employee-id, manager-id) Specify the following queries on this database schema using the relational operators we discussed in class. Write your answers on a separate sheet of paper in the order that they are specified below. Retrieve the name and address of employees who work for First Bank Corporation. Retrieve the name, street address, and city of residence of all employees...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT