Ana sayfa
/
Teknoloji
/
Imagine you are working in a technology company. Your boss wants you to create a simple application to calculate the annual raises of the employees according to their previous 3 years' sale numbers. Also, you want to store those results on a txt document. So you can print it and show it to your boss. Your program will take the employee's name sumame, employee ID, and sales for the first.second and third years as input. All fields are required. Create an employee class It should have fields for name, surname, employee ID, sales for the first month, sales for the second month, sales for the third month, amount of the raise going to be added to the employees' salaries. Use meaningfu names for the fields. Create an instance method to calculate salary raises. SalaryRaise=((25% salesOne)+ (35% salesTwo)+(40% salesThree))^ast 0.2. The remaining functionalities of the class are up to you. You can create the class the way you want it. After submitting your data show a message dialog and clear the form. Override the toString method and use it to write into the ",but file.

Soru

Imagine you are working in a technology company. Your boss wants you to create a simple
application to calculate the annual raises of the employees according to their previous 3 years' sale numbers.
Also, you want to store those results on a txt document. So you can print it and show it to your boss.
Your program will take the employee's name sumame, employee ID, and sales for the first.second
and third years as input. All fields are required.
Create an employee class It should have fields for name, surname, employee ID, sales for the first
month, sales for the second month, sales for the third month, amount of the raise going to be added to the
employees' salaries. Use meaningfu names for the fields.
Create an instance method to calculate salary raises.
SalaryRaise=((25% salesOne)+
(35% salesTwo)+(40% salesThree))^ast 0.2.
The remaining functionalities of the class are up to you. You can create the class the way you want it.
After submitting your data show a message dialog and clear the form.
Override the toString method and use it to write into the ",but file.

Imagine you are working in a technology company. Your boss wants you to create a simple application to calculate the annual raises of the employees according to their previous 3 years' sale numbers. Also, you want to store those results on a txt document. So you can print it and show it to your boss. Your program will take the employee's name sumame, employee ID, and sales for the first.second and third years as input. All fields are required. Create an employee class It should have fields for name, surname, employee ID, sales for the first month, sales for the second month, sales for the third month, amount of the raise going to be added to the employees' salaries. Use meaningfu names for the fields. Create an instance method to calculate salary raises. SalaryRaise=((25% salesOne)+ (35% salesTwo)+(40% salesThree))^ast 0.2. The remaining functionalities of the class are up to you. You can create the class the way you want it. After submitting your data show a message dialog and clear the form. Override the toString method and use it to write into the ",but file.

Çözüm

4.7225 Voting
avatar
Talip
Profesyonel · 6 yıl öğretmeni
Uzman doğrulaması

Cevap

Here's an example implementation of the `Employee` class in Python:<br />```python<br />class Employee:<br /> def __init__(self, name, surname, employee_id, sales_one, sales_two, sales_three):<br /> self.name = name<br /> self.surname = surname<br /> self.employee_id = employee_id<br /> self.sales_one = sales_one<br /> self.sales_two = sales_two<br /> self.sales_three = sales_three<br /> self.salary_raise = 0.0<br /><br /> def calculate_salary_raise(self):<br /> self.salary_raise = ((0.25 * self.sales_one) + (0.35 * self.sales_two) + (0.4 * self.sales_three)) * 0.2<br /><br /> def __str__(self):<br /> return f"{self.name} {self.surname}, {self.employee_id}, {self.sales_one}, {self.sales_two}, {self.sales_three}, {self.salary_raise}"<br /><br /> def save_to_file(self, filename):<br /> with open(filename, "w") as file:<br /> file.write(str(self))<br /> print("Data saved to file successfully!")<br /> self.clear_form()<br /><br /> def clear_form(self):<br /> self.name = ""<br /> self.surname = ""<br /> self.employee_id = ""<br /> self.sales_one = 0.0<br /> self.sales_two = 0.0<br /> self.sales_three = 0.0<br /> self.salary_raise = 0.0<br />```<br />The `Employee` class has the following fields:<br /><br />* `name`: the employee's name<br />* `surname`: the employee's surname<br />* `employee_id`: the employee's ID<br />* `sales_one`: the sales for the first year<br />* `sales_two`: the sales for the second year<br />* `sales_three`: the sales for the third year<br />* `salary_raise`: the amount of the raise going to be added to the employee's salary<br /><br />The class also has the following methods:<br /><br />* `calculate_salary_raise`: calculates the salary raise based on the given formula<br />* `__str__`: returns a string representation of the employee's data, which is used to write the data to the file<br />* `save_to_file`: writes the employee's data to a file with the given filename<br />* `clear_form`: clears the form by setting all fields to empty or zero values<br /><br />To use the class, you can create an instance of the `Employee` class and call its methods like this:<br />```python<br />emp = Employee("John", "Doe", "1234", 1000, 2000, 1500)<br />emp.calculate_salary_raise()<br />emp.save_to_file("employee_data.txt")<br />```<br />This will create an instance of the `Employee` class with the given data, calculate the salary raise, save the data to a file named "employee\_data.txt", and print a message dialog saying "Data saved to file successfully!".
Derecelendirmek için tıklayın: