Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chapter_3;
- import java.util.Scanner;
- public class ComputeTax {
- public static void main(String[] args) {
- // Compute a person's income tax
- Scanner input = new Scanner(System.in);
- //Prompt user for filing status
- System.out.println("Enter your filing status:");
- System.out.println("0 - Single");
- System.out.println("1 - Maried/Joint Filing");
- System.out.println("2 - Married/Separate Filing");
- System.out.println("3 - Head of Household");
- //Get user filing status
- int filingStatus = input.nextInt();
- //Prompt user for taxable income
- System.out.println("\nWhat is your taxable income?");
- //Get user taxable income
- double income = input.nextDouble();
- //Set taxable Income variable
- double taxableIncome = 0;
- //Calculate taxable income for single filers
- if (filingStatus == 0) {
- if (income < 8350) {
- double taxableIncome = income * .1;
- }
- else if (income <= 33950) {
- double taxableIncome = 8350 * 0.10 + (income - 8350) * 0.15;
- }
- else if (income <= 82250) {
- double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
- }
- else if (income <= 171550) {
- double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 +
- (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
- }
- else if (income <= 372950) {
- double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 +
- (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (income -372950) * .33;
- }
- else {
- double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 +
- (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * .33 +
- (income - 372950) * .35;
- }
- }
- else {
- System.out.println("Not filing as single");
- }
- System.out.print(taxableIncome);
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement