import java.util.Scanner;

public class TaxConsoleApp {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("=== Official Federal Income Tax Calculator ===");
        System.out.print("Enter your filing status (\"single\" or \"married\"): ");
        
        // Clean up the string by removing extra spaces and ignoring letter casing
        String statusInput = scanner.next().trim().toLowerCase();
        
        System.out.print("Enter your annual GROSS income: $");
        double grossIncome = scanner.nextDouble();
        
        double taxOwed = 0.0;
        double activeDeduction = 0.0;

        // Use direct, explicit if statements for status selection
        if (statusInput.equalsIgnoreCase("married") || statusInput.equals("married")) {
            activeDeduction = TaxCalculator.MARRIED_DEDUCTION;
            taxOwed = TaxCalculator.calculateMarriedTax(grossIncome);
        } else {
            activeDeduction = TaxCalculator.SINGLE_DEDUCTION;
            taxOwed = TaxCalculator.calculateSingleTax(grossIncome);
        }

        double taxableIncome = TaxCalculator.applyStandardDeduction(grossIncome, activeDeduction);
        
        // Calculate effective rate and round everything to two decimal places
        double effectiveRate = 0.0;
        if (grossIncome > 0) {
            effectiveRate = (taxOwed / grossIncome) * 100.0;
        }

        double roundedGross = Math.round(grossIncome * 100.0) / 100.0;
        double roundedDeduction = Math.round(activeDeduction * 100.0) / 100.0;
        double roundedTaxable = Math.round(taxableIncome * 100.0) / 100.0;
        double roundedTaxOwed = Math.round(taxOwed * 100.0) / 100.0;
        double roundedRate = Math.round(effectiveRate * 100.0) / 100.0;

        // Display results cleanly using simple layout spacing and concatenation
        System.out.println();
        System.out.println("--- Tax Assessment Summary ---");
        System.out.println("Filing Profile:      " + statusInput);
        System.out.println("Gross Income:        $" + roundedGross);
        System.out.println("Standard Deduction: -$" + roundedDeduction);
        System.out.println("Taxable Income:      $" + roundedTaxable);
        System.out.println("------------------------------");
        System.out.println("Total Tax Owed:      $" + roundedTaxOwed);
        System.out.println("Effective Tax Rate:  " + roundedRate + "%");

        scanner.close();
    }
}