1. 程式人生 > >java E201_02_0個稅計算器

java E201_02_0個稅計算器

package 第二章選擇結構;
import java.util.Scanner;
public class E201_02_08個稅計算器 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.printf("請輸入工資數:");
        double wages =scan.nextFloat();//工資
        double taxableIncome ;//應納稅所得額
        double taxAmount;//個稅額
        double other;//超出的部分
        taxableIncome = wages-4200;//應納稅所得額 = (應發工資wages-四金700)-3500
        //個稅額 = 應納稅所得額 *稅率-速算扣除數

        if (taxableIncome<=1500) taxAmount = taxableIncome*0.03-0;
        else if ( taxableIncome>1500 && taxableIncome<=4500 ) taxAmount = (taxableIncome)*0.1-105;
        else if ( taxableIncome>4500 && taxableIncome<=9000 ) taxAmount = (taxableIncome)*0.2-555;
        else if ( taxableIncome>9000 && taxableIncome<=35000 ) taxAmount = (taxableIncome)*0.25-1005;
        else if ( taxableIncome>35000 && taxableIncome<=55000 ) taxAmount = (taxableIncome)*0.3-2755;
        else if ( taxableIncome>55000 && taxableIncome<=80000 ) taxAmount = (taxableIncome)*0.35-5505;
        else
            taxAmount = (taxableIncome)*0.45%-13505;

        System.out.printf("個稅額:%f\n",taxAmount);
        System.out.printf("應到工資:%f",wages-taxAmount-700);
    }
}