使用java编写财务信息类,财务信息类的属性包括:公司名称、定金收入、押金收入、租金收入、其它收入、员工成本、房租、水电、税收及其它费用,方法包括:收入计算、成本计算、净收入计算。
时间: 2023-10-07 20:07:04 浏览: 51
以下是使用Java编写的财务信息类的示例代码:
```java
public class FinancialInfo {
// 公司名称
private String companyName;
// 定金收入
private double earnestIncome;
// 押金收入
private double depositIncome;
// 租金收入
private double rentIncome;
// 其它收入
private double otherIncome;
// 员工成本
private double employeeCost;
// 房租
private double rentCost;
// 水电费
private double utilityCost;
// 税收
private double tax;
// 其它费用
private double otherCost;
// 构造函数
public FinancialInfo(String companyName, double earnestIncome, double depositIncome, double rentIncome,
double otherIncome, double employeeCost, double rentCost, double utilityCost,
double tax, double otherCost) {
this.companyName = companyName;
this.earnestIncome = earnestIncome;
this.depositIncome = depositIncome;
this.rentIncome = rentIncome;
this.otherIncome = otherIncome;
this.employeeCost = employeeCost;
this.rentCost = rentCost;
this.utilityCost = utilityCost;
this.tax = tax;
this.otherCost = otherCost;
}
// 收入计算方法
public double calculateRevenue() {
return earnestIncome + depositIncome + rentIncome + otherIncome;
}
// 成本计算方法
public double calculateCost() {
return employeeCost + rentCost + utilityCost + tax + otherCost;
}
// 净收入计算方法
public double calculateNetIncome() {
return calculateRevenue() - calculateCost();
}
}
```
示例代码中包含了财务信息类的属性和方法:
属性:
1. 公司名称:使用字符串类型的变量存储;
2. 定金收入、押金收入、租金收入、其它收入:使用浮点数类型的变量分别存储;
3. 员工成本、房租、水电费、税收、其它费用:同样使用浮点数类型的变量分别存储。
方法:
1. 收入计算方法:将所有收入相加即可;
2. 成本计算方法:将所有成本相加即可;
3. 净收入计算方法:将收入减去成本即可。
使用示例代码中,我们可以创建一个 `FinancialInfo` 类的实例,并传入公司的各项财务信息,然后调用相应的方法进行计算,得到公司的收入、成本和净收入。