Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this program was lovingly written by Jason Stewart
- import java.util.Scanner;
- public class Tax {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in); //creates scanner
- System.out.print( "(Input one of the following:\n 0-Single Filer\n 2-married separately\n 3-Head of Household\nEnter the filing status: ");
- int status = input.nextInt();
- System.out.print("Enter the taxable income: ");
- double income = input.nextDouble(); //enters the taxable income
- double tax = 0; //placeholder for the tax
- if (status == 0)
- {
- if (income <= 8350)
- tax = income * .10;
- else if (income <= 33950)
- tax = 8350 * .10 + (income - 8350) * 0.15;
- else if (income <= 82250)
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
- else if (income <= 171550)
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25 + (income - 82250) * 0.28;
- else if (income <= 372950)
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25 + (income - 82250) * 0.28 + (income - 171550) * 0.35;
- else
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25 + (income - 82250) * 0.28 + (income - 171550) * 0.33 + (income - 372950) * 0.35;
- }
- if (status == 1)
- {
- if (income <= 16700)
- tax = income * .10;
- else if (income <= 67900)
- tax = 16700 * .10 + (income - 16700) * 0.15;
- else if (income <= 137050)
- tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25;
- else if (income <= 208850)
- tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 + (income - 137050) * 0.28;
- else if (income <= 372950)
- tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 + (income - 137050) * 0.28 + (income - 208850) * 0.33;
- else
- tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 + (income - 137050) * 0.28 + (income - 208850) * 0.33 + (income - 372950) * 0.35;
- }
- if (status == 2)
- {
- if (income <= 8350)
- tax = income * .10;
- else if (income <= 33950)
- tax = 8350 * .10 + (income - 8350) * 0.15;
- else if (income <= 68525)
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25;
- else if (income <= 104425)
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25 + (income - 104425) * 0.28;
- else if (income <= 186475)
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25 + (income - 104425) * 0.28 + (income - 186475) * 0.33;
- else
- tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25 + (income - 104425) * 0.28 + (income - 186475) * 0.33 + (income - 186476) * 0.35;
- }
- if (status == 3)
- {
- if (income <= 11950)
- tax = income * .10;
- else if (income <= 45500)
- tax = 11950 * .10 + (income - 11950) * 0.15;
- else if (income <= 117450)
- tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25;
- else if (income <= 190200)
- tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25 + (income - 190200) * 0.28;
- else if (income <= 372950)
- tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25 + (income - 190200) * 0.28 (income - 392950) * 0.33;
- else
- tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25 + (income - 190200) * 0.28 + (income - 392950) * 0.33 + (income - 372951) * 0.35;
- else {
- System.out.println("Error: Invalid status");
- System.exit(0);
- }
- }
- System.out.println("Tax is " + (int)(tax *100) / 100.0);
- }
- }
Add Comment
Please, Sign In to add comment