个税可以在这里计算:个税计算器2023 - 个人所得税计算器2023 - 工资计算器 (gerensuodeshui.cn)
计算个人所得税的类:TaxCompute.java
public class TaxCompute { double cur_in; // 本月收入 int in_type; // 收入类型 double total_sal; // 从一月开始累积收入 double soc_insur; // 社会保险费(每月) double spe_surcharge;// 专项附加费 int tax_num; // 缴税期数 public double sal_taxable(double total_sal, double soc_insur, double spe_surcharge, int tax_num) { return total_sal - (5000 + soc_insur + spe_surcharge) * tax_num; // 工资应缴纳所得额sal_taxable } public double salary_tax_count(int in_type, double cur_in, double total_sal, double soc_insur, double spe_surcharge, int tax_num) { double st = sal_taxable(total_sal, soc_insur, spe_surcharge, tax_num); if (in_type == 1) { if (st> 960000) return st * 0.45 - 181920; else if (st > 660000) return st * 0.35 - 85920; else if (st > 420000) return st * 0.30 - 52920; else if (st > 300000) return st * 0.25 - 31920; else if (st > 144000) return st * 0.20 - 16920; else if (st > 36000) return st * 0.10 - 2520; else return st * 0.03; } return 0.00; } public double other_tax_count(int in_type, double cur_in) { if (in_type == 2) { double bt = cur_in; // 年终奖应缴纳所得额bonus_taxable double bt_avg = bt / 12; // 年终奖平均每月所得 if (bt_avg > 80000) return bt * 0.45 - 15160; else if (bt_avg > 55000) return bt * 0.35 - 7160; else if (bt_avg > 35000) return bt * 0.30 - 4410; else if (bt_avg > 25000) return bt * 0.25 - 2660; else if (bt_avg > 12000) return bt * 0.20 - 1410; else if (bt_avg > 3000) return bt * 0.1 - 210; else return bt * 0.03; } if (in_type == 3) // 劳务报酬所得 { double lt; // 劳务报酬所得应缴纳所得额 if (cur_in > 4000) lt = cur_in * (1 - 0.20); else lt = cur_in - 800; if (lt > 50000) return lt * 0.40 - 7000; else if (lt > 20000) return lt * 0.30 - 2000; else return lt * 0.20; } else if (in_type == 4) // 稿酬所得 { double rt; // 稿酬所得应缴纳所得额remuneration_taxable if (cur_in > 4000) rt = cur_in * (1 - 0.20); else rt = cur_in - 800; return rt * 0.14; } else if (in_type == 5) // 居民住房租赁 { double ht; // 居民住房租赁应缴纳所得额house_taxable if (cur_in > 4000) ht = cur_in * (1 - 0.20); else ht = cur_in - 800; return ht * 0.10; } else if (in_type == 6) // 除居民租房外的财产租赁 { double pt; // 居民住房租赁应缴纳所得额property_taxable if (cur_in > 4000) pt = cur_in * (1 - 0.20); else pt = cur_in - 800; return pt * 0.20; } else if (in_type == 7) // 利息、股息、红利、偶然所得 { return cur_in * 0.20; } else return 0.00; }}创建主函数:Taxtest.java
import java.util.Scanner;public class TaxTest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("收入类型编号对应: " + "1.工资薪酬 " + "2.年终奖 " + "3.劳务报酬 " + "4.稿酬所得 " + "5.居民住房租赁所得 " + "6.除居民租房租赁外的财产租赁所得 " + "7.利息、股息、红利、偶然所得"); System.out.println("请输入收入类型编号:"); int t = sc.nextInt(); // 收入类型 System.out.println("请输入本月要计算的收入:"); double cur_in = sc.nextDouble(); TaxCompute TC1 = new TaxCompute(); if (t == 1) { System.out.println("请输入从一月到本月的累积工资:"); double total_sal = sc.nextDouble(); System.out.println("请输入社会保险费用:"); double soc_insur = sc.nextDouble(); System.out.println("请输入每个月的专项附加扣除费"); double spe_surcharge = sc.nextDouble(); System.out.println("请输入要计算的缴税期数:"); int tax_num = sc.nextInt(); if (t == 1) { System.out.println( "累计应缴税款:" + TC1.salary_tax_count(t, cur_in, total_sal, soc_insur, spe_surcharge, tax_num)); } } else if (t==2){ System.out.println( "累计应缴税款:" + TC1.other_tax_count(t, cur_in)); } else{ System.out.println("累计应缴税款:" + TC1.other_tax_count(t, cur_in)); } }}测试结果: