编写财务信息类,财务信息类的属性包括:公司名称、定金收入、押金收入、租金收入、其它收入、员工成本、房租、水电、税收及其它费用,方法包括:收入计算、成本计算、净收入计算。 结果如下图 image.png
时间: 2023-10-11 15:09:55 浏览: 26
下面是一个简单的财务信息类的实现,包括属性和方法的定义以及结果输出:
```python
class FinancialInfo:
def __init__(self, company_name, deposit_income, rent_income, other_income, employee_cost, rent_cost, utilities_cost, tax_cost, other_cost):
self.company_name = company_name
self.deposit_income = deposit_income
self.rent_income = rent_income
self.other_income = other_income
self.employee_cost = employee_cost
self.rent_cost = rent_cost
self.utilities_cost = utilities_cost
self.tax_cost = tax_cost
self.other_cost = other_cost
def income_calculation(self):
total_income = self.deposit_income + self.rent_income + self.other_income
return total_income
def cost_calculation(self):
total_cost = self.employee_cost + self.rent_cost + self.utilities_cost + self.tax_cost + self.other_cost
return total_cost
def net_income_calculation(self):
total_income = self.income_calculation()
total_cost = self.cost_calculation()
net_income = total_income - total_cost
return net_income
# 测试
info = FinancialInfo("ABC公司", 10000, 20000, 3000, 8000, 5000, 2000, 3000, 1000)
print("{0:<10s}{1:<10s}".format("项目", "金额"))
print("{0:<10s}{1:<10d}".format("定金收入", info.deposit_income))
print("{0:<10s}{1:<10d}".format("租金收入", info.rent_income))
print("{0:<10s}{1:<10d}".format("其它收入", info.other_income))
print("{0:<10s}{1:<10d}".format("员工成本", info.employee_cost))
print("{0:<10s}{1:<10d}".format("房租", info.rent_cost))
print("{0:<10s}{1:<10d}".format("水电", info.utilities_cost))
print("{0:<10s}{1:<10d}".format("税收", info.tax_cost))
print("{0:<10s}{1:<10d}".format("其它费用", info.other_cost))
print("-" * 20)
print("{0:<10s}{1:<10d}".format("总收入", info.income_calculation()))
print("{0:<10s}{1:<10d}".format("总成本", info.cost_calculation()))
print("{0:<10s}{1:<10d}".format("净收入", info.net_income_calculation()))
```
输出结果:
```
项目 金额
定金收入 10000
租金收入 20000
其它收入 3000
员工成本 8000
房租 5000
水电 2000
税收 3000
其它费用 1000
--------------------
总收入 33000
总成本 19000
净收入 14000
```
以上代码仅供参考,实际应用中可能需要根据具体的业务需求进行修改和扩展。
相关推荐
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)