Bài tập  /  Bài đang cần trả lời

Xây dựng chương trình quản lý nhân viên gồm họ tên, ngày sinh, giới tính, mã nhân viên, Số CMT, lương cơ bản, phụ cấp

Xây dựng chương trình quản lý Nhanvien gồm họ tên, ngày sinh, giới tính, mã nhân viên, Số CMT, lương cơ bản, phụ cấp.

Các chương trình con: 

 Xây dựng chương trình con nhập thông tin của  n nhân viên.
 Xây dựng chương trình con xuất thông tin của  n nhân viên.
 Xây dựng chương trình con nhập 2 mã nhân viên để so sánh tuổi của hai nhân viên trong công ty.
 Xây dựng  chương trình con tính lương của nhân viên biết rằng lương=lương cơ bản *3+ phụ cấp.
 Xây dựng chương trình con để sắp xếp tuổi nhân viên tăng dần 
 Xây dựng chương trình con để tìm kiếm thông tin nhân viên qua mã nhân viên
1 trả lời
Hỏi chi tiết
204
0
0
Phạm Khải
05/02/2023 12:12:55

Python

class Employee:
    def __init__(self, name, birthdate, gender, employee_id, id_number, basic_salary, allowance):
        self.name = name
        self.birthdate = birthdate
        self.gender = gender
        self.employee_id = employee_id
        self.id_number = id_number
        self.basic_salary = basic_salary
        self.allowance = allowance

    def calculate_salary(self):
        return self.basic_salary * 3 + self.allowance


def input_employees(employee_list, n):
    for i in range(n):
        name = input("Enter name of employee {}:".format(i+1))
        birthdate = input("Enter birthdate of employee {}:".format(i+1))
        gender = input("Enter gender of employee {}:".format(i+1))
        employee_id = input("Enter employee ID of employee {}:".format(i+1))
        id_number = input("Enter ID number of employee {}:".format(i+1))
        basic_salary = float(input("Enter basic salary of employee {}:".format(i+1)))
        allowance = float(input("Enter allowance of employee {}:".format(i+1)))
        employee_list.append(Employee(name, birthdate, gender, employee_id, id_number, basic_salary, allowance))


def output_employees(employee_list):
    for employee in employee_list:
        print("Name: ", employee.name)
        print("Birthdate: ", employee.birthdate)
        print("Gender: ", employee.gender)
        print("Employee ID: ", employee.employee_id)
        print("ID number: ", employee.id_number)
        print("Basic salary: ", employee.basic_salary)
        print("Allowance: ", employee.allowance)
        print("Salary: ", employee.calculate_salary())
        print("\n")


def compare_ages(employee_list, employee_id1, employee_id2):
    employee1 = None
    employee2 = None
    for employee in employee_list:
        if employee.employee_id == employee_id1:
            employee1 = employee
        if employee.employee_id == employee_id2:
            employee2 = employee
    if employee1 is None or employee2 is None:
        print("Invalid employee IDs")
        return

    if employee1.birthdate > employee2.birthdate:
        print("Employee 1 is older")
    elif employee1.birthdate < employee2.birthdate:
        print("Employee 2 is older")
    else:
        print("Both employees have the same age")


def sort_by_age(employee_list):
    employee_list.sort(key=lambda x: x.birthdate)


def search_employee(employee_list, employee_id):
    for employee in employee_list:
        if employee.employee_id == employee_id:
            print("Name: ", employee.name)
 

Mở khóa để xem toàn bộ nội dung trả lời

(?)
Bạn đã đạt đến giới hạn của mình. Bằng cách Đăng ký tài khoản, bạn có thể xem toàn bộ nội dung trả lời
Cải thiện điểm số của bạn bằng cách đăng ký tài khoản Lazi.
Xem toàn bộ các câu trả lời, chat trực tiếp 1:1 với đội ngũ Gia sư Lazi bằng cách Đăng nhập tài khoản ngay bây giờ
Tôi đã có tài khoản? Đăng nhập

Bạn hỏi - Lazi trả lời

Bạn muốn biết điều gì?

GỬI CÂU HỎI
Học tập không giới hạn cùng học sinh cả nước và AI, sôi động, tích cực, trải nghiệm
Bài tập liên quan
Bài tập Lập trình Đại học mới nhất

Hôm nay bạn thế nào? Hãy nhấp vào một lựa chọn, nếu may mắn bạn sẽ được tặng 50.000 xu từ Lazi

Vui Buồn Bình thường

Học ngoại ngữ với Flashcard

×
Gia sư Lazi Gia sư
×
Trợ lý ảo Trợ lý ảo