/** * TaxProgram compute tax according to marital status and income. * * @author (Andrew Samuels) * @version (02-19-2010) */ //import scanner import java.util.Scanner; public class TaxProgram { public static void main(String[] args) { //create variables int income; int taxAmount; String maritalStatus; //create scanner Scanner keyboard = new Scanner(System.in); //capture income from user System.out.print("Please enter income: "); income = keyboard.nextInt(); //capture marital status from user System.out.print("Please enter marital status (single, married): "); maritalStatus = keyboard.next(); //determine tax amount from marital status and income if ((maritalStatus.equals("single") || maritalStatus.equals("Single")) && income < 30000) { taxAmount = income * 1/5; System.out.println("Tax amount is: " + taxAmount); } else if ((maritalStatus.equals("single") || maritalStatus.equals("Single")) && income > 30000) { taxAmount = income * 1/4; System.out.println("Tax amount is: " + taxAmount); } else if ((maritalStatus.equals("married") || maritalStatus.equals("Married")) && income < 50000) { taxAmount = income * 1/10; System.out.println("Tax amount is: " + taxAmount); } else if ((maritalStatus.equals("married") || maritalStatus.equals("Married")) && income > 50000) { taxAmount = income * 3/20; System.out.println("Tax amount is: " + taxAmount); } } }
I am a software engineer with a computational physics focus. The purpose of this blog is to showcase my ideas and works. I can create value and reduce costs for your company.