import java.util.Scanner; /** * An application to help determine whether you need to file taxes * * This class illustrates: * - Why helper methods should be private (instead of public) * - How private methods can help reduce the amount of repetition in your code * thereby making your code shorter, more readable, and easier to modify/extend/maintain. * * @author alchambers * @version sp19 */ public class TaxHelper{ // This main method is 78 lines long! public static void main(String[] args){ 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("Please type \"yes\" or \"no\" for each question"); System.out.println("======================================="); System.out.println(); Scanner input = new Scanner(System.in); System.out.println("Are you married? (yes/no)"); String answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Are you and your spouse both over 65?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Is your combined gross income more than $30,000?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Yes, you must file taxes"); } else{ System.out.println("No, you do not need to file taxes"); } } else{ System.out.println("Is one of you over 65?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Is your combined gross income more than $27, 000?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Yes, you must file taxes"); } else{ System.out.println("No, you do not need to file taxes"); } } else{ System.out.println("Is your combined gross income more than $25,000?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Yes, you must file taxes"); } else{ System.out.println("No, you do not need to file taxes"); } } } } else{ System.out.println("Are you over 65 years of age?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Is your gross income more than $27,000?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Yes, you must file taxes"); } else{ System.out.println("No, you do not need to file taxes"); } } else{ System.out.println("Is your gross income more than $24,500?"); answer = input.nextLine(); if(answer.equals("yes")){ System.out.println("Yes, you must file taxes"); } else{ System.out.println("No, you do not need to file taxes"); } } } } }