import java.util.Scanner; /** * This is the original version of TaxHelper. This class illustrates * the use of nested conditionals. */ public class TaxHelper{ private Scanner scan; /** * Creates a new tax helper */ public TaxHelper(){ scan = new Scanner(System.in); printWelcomeMessage(); } /** * Helps the user determine whether or not they need to file taxes */ public void determineFilingStatus(){ System.out.println("Are you single? (y/n)"); String input = scan.nextLine(); // Single if(input.equals("y")){ System.out.println("Are you under 65 years of age?"); input = scan.nextLine(); // Under 65 years old if(input.equals("y")){ System.out.println("Is your gross income less than $8450?"); input = scan.nextLine(); // Less than income threshold if(input.equals("y")){ System.out.println("No, you do not need to file taxes"); } // More than income threshold else{ System.out.println("Yes, you must file taxes"); } } // Over 65 years old else{ System.out.println("Is your gross income less than $9700?"); input = scan.nextLine(); // Less than income threshold if(input.equals("y")){ System.out.println("No, you do not need to file taxes"); } // More than income threshold else{ System.out.println("Yes, you must file taxes"); } } } // Married else{ System.out.println("Are you and your spouse both over 65?"); input = scan.nextLine(); // Over 65 if(input.equals("y")){ System.out.println("Is your combined gross income less than $23, 000?"); input = scan.nextLine(); // Less than income threshold if(input.equals("y")){ System.out.println("No, you do not need to file taxes"); } // More than income threshold else{ System.out.println("Yes, you must file taxes"); } } // At least one person is under 65 else{ System.out.println("Are you and your spouse both under 65?"); input = scan.nextLine(); // Both under 65 if(input.equals("y")){ System.out.println("Is your combined gross income less than $20,600?"); input = scan.nextLine(); // Less than income threshold if(input.equals("y")){ System.out.println("No, you do not need to file taxes"); } // More than income threshold else{ System.out.println("Yes, you must file taxes"); } } // One person over 65 and one person under 65 else{ System.out.println("Is your combined gross income less than $21, 800?"); input = scan.nextLine(); // Less than income threshold if(input.equals("y")){ System.out.println("No, you do not need to file taxes"); } // More than income threshold else{ System.out.println("Yes, you must file taxes"); } } } } } /*================================================================ * Below are the private helper methods *================================================================*/ /** * Prints a welcome message to the user */ private void printWelcomeMessage(){ System.out.println("======================================="); System.out.println("Welcome to the Tax Center!"); System.out.println("We offer non-professional tax help."); System.out.println("Use at your own risk!"); System.out.println(); } }