java从控制台输入每月的基本工资和绩效工资,并计算输出员工一年到手工资,其中:交通补贴100元,电话补贴200元;公积金个人扣10%;各种保险个人扣8%;个人所得税交5%。
时间: 2024-10-17 19:09:14 浏览: 36
在Java中,你可以创建一个简单的程序来实现这个功能。首先,你需要定义一个`Employee`类,包含基本工资和绩效工资的属性,以及一些辅助方法来进行计算。以下是一个简单的示例:
```java
import java.util.Scanner;
class Employee {
double basicSalary;
double performanceSalary;
// 构造函数
public Employee(double basic, double performance) {
this.basicSalary = basic;
this.performanceSalary = performance;
}
// 计算月工资
double calculateMonthlyPay() {
return basicSalary + performanceSalary;
}
// 计算年工资
double calculateAnnualPay(int months) {
return calculateMonthlyPay() * months;
}
// 计算扣除后的年工资
double calculateNetAnnualPay(int months) {
double annualBeforeDeductions = calculateAnnualPay(months);
double deductions = (annualBeforeDeductions * 0.1) + (annualBeforeDeductions * 0.08); // 公积金和个人保险扣款
double tax = annualBeforeDeductions * 0.05; // 个人所得税
double netAnnualPay = annualBeforeDeductions - 100 - 200; // 减去补贴
return netAnnualPay;
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入基本工资:");
double basic = scanner.nextDouble();
System.out.println("请输入绩效工资:");
double performance = scanner.nextDouble();
System.out.println("请输入工作月份(按12个月计算):");
int months = scanner.nextInt();
Employee employee = new Employee(basic, performance);
double annualNetPay = employee.calculateNetAnnualPay(months);
System.out.printf("员工一年到手工资为: %.2f元\n", annualNetPay);
scanner.close();
}
}
```
在这个程序中,用户会被提示输入基本工资、绩效工资和工作月份数。然后会计算出扣除补贴、公积金、保险和个人所得税后的年工资。
阅读全文