Kali ini saya akan membagikan menghitung pajak pada pemrograman java, selamat berpusing-pusing riya, .. . hhe
Selamat mencoba, . .
import java.util.Scanner;
public class ComputeTaxes {
public static void main(String[] iriahus) {
@SuppressWarnings("resource")
Scanner s = new Scanner(System.in);
System.out.println("2009 U.S. Federal Personal Tax Rates");
System.out.println("------------------------------------\n");
System.out.println("Filling status is classified as follow:");
System.out.print(" 1 - Single\n" +
" 2 - Married Jointly or Qualifying Widow(er)\n" +
" 3 - Married Separately\n" +
" 4 - Head of Household\n\n" +
"Enter filling status: ");
int status = s.nextInt();
System.out.print("Enter the taxable income: ");
double income = s.nextDouble();
double tax = 0;
if (status < 1 || status > 4 || income < 0) {
System.out.println("Invalid input!");
System.exit(status);
}
else if (status == 1) {
if (income <= 8350)
tax = 0.10 * income;
else if (income <= 33950)
tax = 0.10 * 8350 + 0.15 * (income - 8350);
else if (income <= 82250)
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (income - 33950);
else if (income <= 171550)
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (82250 - 33950) +
0.28 * (income - 82250);
else if (income <= 372950)
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (82250 - 33950) +
0.28 * (171550 - 82250) + 0.33 * (income - 171550);
else
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (82250 - 33950) +
0.28 * (171550 - 82250) + 0.33 * (372950 - 171550) + 0.35 * (income - 372950);
}
else if (status == 2) {
if (income <= 16700)
tax = 0.10 * income;
else if (income <= 67900)
tax = 0.10 * 16700 + 0.15 * (income - 16700);
else if (income <= 137050)
tax = 0.10 * 16700 + 0.15 * (67900 - 16700) + 0.25 * (income - 67900);
else if (income <= 208850)
tax = 0.10 * 16700 + 0.15 * (67900 - 16700) + 0.25 * (137050 - 67900) +
0.28 * (income - 137050);
else if (income <= 372950)
tax = 0.10 * 16700 + 0.15 * (67900 - 16700) + 0.25 * (137050 - 67900) +
0.28 * (208850 - 137050) + 0.33 * (income - 208850);
else
tax = 0.10 * 16700 + 0.15 * (67900 - 16700) + 0.25 * (137050 - 67900) +
0.28 * (208850 - 137050) + 0.33 * (372950 - 208850) + 0.35 * (income - 372950);
}
else if (status == 3) {
if (income <= 8350)
tax = 0.10 * income;
else if (income <= 33950)
tax = 0.10 * 8350 + 0.15 * (income - 8350);
else if (income <= 68525)
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (income - 33950);
else if (income <= 104425)
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (68525 - 33950) +
0.28 * (income - 68525);
else if (income <= 186475)
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (68525 - 33950) +
0.28 * (104425 - 68525) + 0.33 * (income - 104425);
else
tax = 0.10 * 8350 + 0.15 * (33950 - 8350) + 0.25 * (68525 - 33950) +
0.28 * (104425 - 68525) + 0.33 * (186475 - 104425) + 0.35 * (income - 186475);
} else {
if (income <= 11950)
tax = 0.10 * income;
else if (income <= 45500)
tax = 0.10 * 11950 + 0.15 * (income - 11950);
else if (income <= 117450)
tax = 0.10 * 11950 + 0.15 * (45500 - 11950) + 0.25 * (income - 45500);
else if (income <= 190200)
tax = 0.10 * 11950 + 0.15 * (45500 - 11950) + 0.25 * (117450 - 45500) +
0.28 * (income - 117450);
else if (income <= 372950)
tax = 0.10 * 11950 + 0.15 * (45500 - 11950) + 0.25 * (117450 - 45500) +
0.28 * (190200 - 117450) + 0.33 * (income - 190200);
else
tax = 0.10 * 11950 + 0.15 * (45500 - 11950) + 0.25 * (117450 - 45500) +
0.28 * (190200 - 117450) + 0.33 * (372950 - 190200) + 0.35 * (income - 372950);
}
System.out.println("The tax is " + tax);
System.out.println("The net income is " + (income - tax));
}
}
0 Response to "Menghitung Pajak"
Post a Comment