怎样用java编写个人所得税公式呀?

怎样用java编写个人所得税公式呀?,第1张

java计算个税例子:

/**

* @author Kun Sun

* @Date: 2013.10.15

*/

public class Employee { // 雇员类

private String ID      // ID

private String name    // 姓名

private int salary     // 工资薪金所得

private int insureHome // “五险一金”数额

private int deduct     // 扣除数额

Employee(){

}

Employee(String ID,String name){ // 带参数的构造方法

this.ID = ID

this.name = name

}

Employee(String ID,String name,int salary,int insureHome,int deduct){  // 带参数的构造方法

this.ID = ID

this.name = name

this.salary = salary

this.insureHome = insureHome

   this.deduct = deduct

}

public String getID() {

return ID

}

public String getName() {

return name

}

public int getSalary() {

return salary

}

public int getInsureHome() {

return insureHome

}

public int getDeduct() {

return deduct

}

public void setID(String iD) {

ID = iD

}

public void setName(String name) {

this.name = name

}

public void setSalary(int salary) {

this.salary = salary

}

public void setInsureHome(int insureHome) {

this.insureHome = insureHome

}

public void setDeduct(int deduct) {

this.deduct = deduct

}

public void selfValue(){ // 个人所得税具体计算

double sefValue

   if(salary>=0 &&salary<1500){

    sefValue = (double)(salary-insureHome-deduct)*0.03 - 0

   }else if(salary>=1500 &&salary<4500){

    sefValue = (double)(salary-insureHome-deduct)*0.1 - 105

   }else if(salary>=4500 &&salary<9000){

    sefValue = (double)(salary-insureHome-deduct)*0.2 - 555

   }else if(salary>=9000 &&salary<35000){

    sefValue = (double)(salary-insureHome-deduct)*0.25 - 1005

   }else if(salary>=35000 &&salary<55000){

    sefValue = (double)(salary-insureHome-deduct)*0.30 - 2755

   }else if(salary>=55000 &&salary<80000){

    sefValue = (double)(salary-insureHome-deduct)*0.35 - 5505

   }else{

    sefValue = (double)(salary-insureHome-deduct)*0.45 - 13505

   }

   System.out.println(sefValue)

}

}

// 用于测试雇员类

public class MainClass {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("第一种调用方法:")

Employee emp = new Employee("1001","Sun")

emp.setSalary(12345)

emp.setInsureHome(890)

emp.setDeduct(55)

System.out.println("编号为"+emp.getID()+",姓名是"+emp.getName()+" 的应纳税额是:")

   emp.selfValue()

 

   System.out.println("------------------------\n第二种调用方法:")

   Employee emp2 = new Employee("1001","Sun",12345,890,55)

System.out.println("编号为"+emp2.getID()+",姓名是"+emp2.getName()+" 的应纳税额是:")

   emp2.selfValue()

 

   System.out.println("------------------------\n第二种调用方法:")

   Employee emp3 = new Employee()

   emp3.setID("1001")

   emp3.setName("Sun")

emp3.setSalary(12345)

emp3.setInsureHome(890)

emp3.setDeduct(55)

System.out.println("编号为"+emp3.getID()+",姓名是"+emp3.getName()+" 的应纳税额是:")

   emp3.selfValue()

}

}

运行结果:

package com.hmall

import java.util.*

public class test {

private static double rate(double money){

if (money<=2000&&money>=0){

return 0

}else if (money<=5000){

return money*0.05

}else if (money<=8000){

return money*0.1

}else if (money<10000){

return money*0.15

}else{

return money*0.2

}

}

public static void main(String[] args){

Scanner scanner = new Scanner(System.in)

System.out.println("请输入金额")

Double money = null

while (true){

money = scanner.nextDouble()

Double rate = rate(money)

System.out.println("应缴纳个人所得税为"+rate+"元")

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11449801.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存