public class IncomeTax {
public static double tax(Employee em) {
double tax=0
double per=0
double over=em.getSalary()+em.getSubsidy()-2000
if(over>20000){
per=0.3
}else if(over>5000){
per=0.2
}else if(over>2000){
per=0.15
}else if(over>500){
per=0.1
}else if(over>0){
per=0.05
}else{
per=0
}
tax=over*per
return tax
}
public static void main(String[] args) {
Employee em=new Employee()
Scanner input=new Scanner(System.in)
System.out.println("请输入员工的姓名:")
em.setName(input.nextLine())
System.out.println("请输入员工的工资返巧蔽:"漏州)
em.setSalary(Double.parseDouble(input.nextLine()))
System.out.println("请输入员工加班补贴:")
em.setSubsidy(Double.parseDouble(input.nextLine()))
double tax=tax(em)
double before=em.getSalary()+em.getSubsidy()
double after=before-tax
System.out.println("员宽扒工"+em.getName()+"的税前收入为"+before+"元,税后收入为"+after+"元,您缴纳的个人所得税为"+tax+"元。")
}
}
public class Employee {
private String name
private double salary
private double subsidy
public String getName() {
return name
}
public void setName(String name) {
this.name=name
}
public double getSalary() {
return salary
}
public void setSalary(double salary) {
this.salary=salary
}
public double getSubsidy() {
return subsidy
}
public void setSubsidy(double subsidy) {
this.subsidy=subsidy
}
}
作用域的问题,修改如下:import java.io.*
public class GongZi{
public static void main(String args[]){
String str=""
System.out.print("芦镇请首哗竖输入者大工资金额:")
try{
BufferedReader input=new BufferedReader(newInputStreamReader(System.in))
str=input.readLine()
}catch(IOException e){}
int qian=Integer.parseInt(str)
double shui = 0
if(qian<=1000){
shui=0
}else if(qian>1000&&qian<=1500){//100应改为1000
shui=(qian-1000)*0.05
}else if(qian>1500&&qian<=5000){
shui=(qian-1500)*0.2+25
}else if(qian>5000&&qian<=10000){
shui=(qian-5000)*0.3+725
}else{
shui=(qian-10000)*0.4+2225
}
System.out.println("您需要缴纳的税款为:"+shui)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)