被你的題目害了,500以下的稅率沒有,害我怎么也算不出11025總是11000,最后被我發(fā)現(xiàn)了 還有個5%的稅率呢。。哎
成都創(chuàng)新互聯(lián)公司于2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站制作、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元廊坊做網(wǎng)站,已為上家服務(wù),為廊坊各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792
代碼如下:import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Tax {
public static void main(String[] args) {
double money = 0.0d, tax = 0.0d, cha = 0.0d;
int n = 2000;
System.out.println("請輸入您的工資水平(數(shù)字):");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
money = Double.parseDouble(in.readLine());
cha = money - n;
if (cha 500 cha = 2000) {
tax = 25 + (cha - 500) * 0.10;
} else if (cha 2000 cha = 5000) {
tax = 25 + 150 + (cha - 2000) * 0.15;
} else if (cha 5000 cha = 20000) {
tax = 25 + 150 + 450 + (cha - 5000) * 0.20;
} else if (cha 20000 cha = 40000) {
tax = 25 + 150 + 450 + 3000 + (cha - 20000) * 0.25;
} else if (cha 40000 cha = 60000) {
tax = 25 + 150 + 450 + 3000 + 5000 + (cha - 40000) * 0.3;
} else if (cha 60000 cha = 80000) {
tax = 25 + 150 + 450 + 3000 + 5000 + 6000 + (cha - 60000)
* 0.35;
} else if (cha 80000 cha = 100000) {
tax = 25 + 150 + 450 + 3000 + 5000 + 6000 + 7000
+ (cha - 80000) * 0.4;
} else if (cha 100000) {
tax = 25 + 150 + 450 + 3000 + 5000 + 6000 + 7000 + 8000
+ (cha - 100000) * 0.45;
}else{
tax = money*0.05;
}
} catch (NumberFormatException e) {
System.out.println("您輸入的工資數(shù)據(jù)類型不是純數(shù)字,不能計(jì)算!");
} catch (IOException e) {
System.out.println("輸入出現(xiàn)異常,請重新運(yùn)行程序。");
}
System.out.println("稅后您應(yīng)得:" + (money - tax));
System.out.println("應(yīng)繳稅為:" + tax);
}
}
首先寫JAVABEAN文件:WageTax.java/**nbsp;*nbsp;*nbsp;@authornbsp;劍江帝國nbsp;*nbsp;@usagenbsp;計(jì)算個人所得稅nbsp;*nbsp;@datenbsp;2008-10-8nbsp;*/publicnbsp;classnbsp;WageTaxnbsp;implementsnbsp;java.io.Serializable{nbsp;nbsp;nbsp;nbsp;privatenbsp;doublenbsp;wage;//定義工資nbsp;nbsp;nbsp;nbsp;privatenbsp;Stringnbsp;output=““;//定義輸入nbsp;nbsp;nbsp;nbsp;/**nbsp;nbsp;nbsp;nbsp;nbsp;*nbsp;輸入一個字符串,代表工資,如果輸入出錯會將錯誤寫至outputnbsp;nbsp;nbsp;nbsp;nbsp;*/nbsp;nbsp;nbsp;nbsp;publicnbsp;voidnbsp;setWage(Stringnbsp;wageInput){nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;try{nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;this.wage=Double.parseDouble(wageInput);nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;catch(Exceptionnbsp;ex){nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;output=“輸入有誤“;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;this.wage=-1;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;/**nbsp;nbsp;nbsp;nbsp;nbsp;*nbsp;計(jì)算稅額,算法簡單說一下。nbsp;nbsp;nbsp;nbsp;nbsp;*/nbsp;nbsp;nbsp;nbsp;publicnbsp;doublenbsp;countTax(){nbsp;nbsp;nbsp;nbsp;nbsp;ifnbsp;(wage-2000amp;gt;0){nbsp;nbsp;nbsp;nbsp;//第一步,將個人的工資減去2000后按交稅等級分成若干個收入塊nbsp;nbsp;nbsp;nbsp;//第二步,按對應(yīng)稅率統(tǒng)計(jì)每個塊應(yīng)該交稅額并相加,之后返回nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;//STEP1nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;wage=wage-2000;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;doublenbsp;rate[]={0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45};nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;intnbsp;bound[]={0,500,2000,5000,20000,40000,60000,80000,100000};nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;doublenbsp;chunk[]={0,0,0,0,0,0,0,0,0};nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;for(intnbsp;i=1;iamp;lt;9;i++){nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;ifnbsp;(wage-bound[i]+bound[i-1]amp;gt;0)nbsp;{nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;wage=wage-bound[i]+bound[i-1];nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;chunk[i-1]=bound[i]-bound[i-1];nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;else{nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;chunk[i-1]=wage;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;wage=-1;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;break;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;ifnbsp;(wageamp;gt;0)nbsp;chunk[8]=wage;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;doublenbsp;tax=0;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;for(intnbsp;i=0;iamp;lt;9;i++){nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;tax=tax+chunk[i]*rate[i];nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;returnnbsp;tax;nbsp;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;nbsp;elsenbsp;returnnbsp;0;nbsp;nbsp;nbsp;nbsp;}nbsp;nbsp;nbsp;nbsp;/**nbsp;nbsp;nbsp;nbsp;nbsp;*nbsp;獲得稅款數(shù)nbsp;nbsp;nbsp;nbsp;nbsp;*/nbsp;nbsp;nbsp;nbsp;publicnbsp;Stringnbsp;getTax(){nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;ifnbsp;(output.equals(““)){nbsp;nbsp;nbsp;nbsp;returnnbsp;Double.toString(countTax());}nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;elsenbsp;returnnbsp;output;nbsp;nbsp;nbsp;nbsp;}}///////////////////////////////////////////////////////然后在輸出頁面中使用設(shè)定wage屬性為工資,獲得tax屬性得到稅
JAVA計(jì)算工人工資,參考例子如下:
import java.util.Scanner;
public class Demo00 {
//定義一個三維數(shù)組,用于記錄每個部門、分支、績效工資
private static final float[][][] SALARY_OF_PER_HOUR = {
{{10.75f,12.50f,14.50f},{11.75f,14.50f,17.50f}},
{{13.00f,16.00f,18.50f},{15.00f,18.50f,22.00f}},
{{16.75f,18.50f,20.50f},{19.25f,25.00f,30.00f}}
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//輸入姓名
System.out.println("請輸入姓名:");
String name = sc.nextLine();
//輸入部門并驗(yàn)證
System.out.println("請輸入部門: A,B,C");
char dept = sc.nextLine().charAt(0);
if(dept'A'||dept'C')
{
System.out.println("輸入有誤,系統(tǒng)將退出");
System.exit(0);
}
//輸入分支機(jī)構(gòu)并驗(yàn)證
System.out.println("請輸入分支機(jī)構(gòu): 1,2");
char div = sc.nextLine().charAt(0);
if(div'1'||div'2')
{
System.out.println("輸入有誤,系統(tǒng)將退出");
System.exit(0);
}
//輸入薪績表并驗(yàn)證
System.out.println("請輸入薪績表: a,b,c");
char sal = sc.nextLine().charAt(0);
if(sal'a'||sal'c')
{
System.out.println("輸入有誤,系統(tǒng)將退出");
System.exit(0);
}
//輸入小時數(shù)
System.out.println("請輸入本周工作時間(整小時數(shù)):");
int hours = sc.nextInt();
float salary = 0;
//每個小時的薪水
float salaryPerHour = SALARY_OF_PER_HOUR[dept-'A'][div-'1'][sal-'a'];
//分別計(jì)算40小時內(nèi)和超過40小時的薪水
if(hours=40)
{
salary += salaryPerHour*hours;
}
else
{
salary += salaryPerHour*hours+(hours-40)*1.5*salaryPerHour;
}
//輸出結(jié)果
System.out.println("姓名:\t"+name+"\n部門:\t"+dept+"\n分支機(jī)構(gòu):\t"+div
+"\n薪績表:\t"+sal+"\n工作時間:\t"+hours+"\n薪水:\t"+salary);
}
}
//Best wishes!
java計(jì)算個稅例子:
/**
* @author Kun Sun
* @Date: 2013.10.15
*/
public class Employee { // 雇員類
private String ID; ? ? ? // ID
private String name; ? ? // 姓名
private int salary; ? ? ?// 工資薪金所得
private int insureHome; ?// “五險(xiǎn)一金”數(shù)額
private int deduct; ? ? ?// 扣除數(shù)額
Employee(){
}
Employee(String ID,String name){ // 帶參數(shù)的構(gòu)造方法
this.ID = ID;
this.name = name;
}
Employee(String ID,String name,int salary,int insureHome,int deduct){ ?// 帶參數(shù)的構(gòu)造方法
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(){ // 個人所得稅具體計(jì)算
double sefValue;
? ?if(salary=0 salary1500){
? ? sefValue = (double)(salary-insureHome-deduct)*0.03 - 0;
? ?}else if(salary=1500 salary4500){
? ? sefValue = (double)(salary-insureHome-deduct)*0.1 - 105;
? ?}else if(salary=4500 salary9000){
? ? sefValue = (double)(salary-insureHome-deduct)*0.2 - 555;
? ?}else if(salary=9000 salary35000){
? ? sefValue = (double)(salary-insureHome-deduct)*0.25 - 1005;
? ?}else if(salary=35000 salary55000){
? ? sefValue = (double)(salary-insureHome-deduct)*0.30 - 2755;
? ?}else if(salary=55000 salary80000){
? ? 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("第一種調(diào)用方法:");
Employee emp = new Employee("1001","Sun");
emp.setSalary(12345);
emp.setInsureHome(890);
emp.setDeduct(55);
System.out.println("編號為"+emp.getID()+",姓名是"+emp.getName()+" 的應(yīng)納稅額是:");
? ?emp.selfValue();
?
? ?System.out.println("------------------------\n第二種調(diào)用方法:");
? ?Employee emp2 = new Employee("1001","Sun",12345,890,55);
System.out.println("編號為"+emp2.getID()+",姓名是"+emp2.getName()+" 的應(yīng)納稅額是:");
? ?emp2.selfValue();
?
? ?System.out.println("------------------------\n第二種調(diào)用方法:");
? ?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()+" 的應(yīng)納稅額是:");
? ?emp3.selfValue();
}
}
運(yùn)行結(jié)果:
文章名稱:稅收計(jì)算Java代碼 java編寫個人所得稅計(jì)算程序
文章網(wǎng)址:http://muchs.cn/article14/ddcijde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、關(guān)鍵詞優(yōu)化、網(wǎng)站策劃、品牌網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)