import javax.swing.JOptionPane;
public class ch0301{
    public static void main(String[] args) {
         // Prompt the user to enter filing status
    String statusString= JOptionPane.showInputDialog(null,"Enter the filing status:\n"+"(0-single filer,1-married JOintly,\n"+"2-married separately,3-head of household)","Example 3.1 Input",JOptionPane.QUESTION_MESSAGE);
	int status=Integer.parseInt(statusString);
	//Prompt the user to enter taxable income
	String incomeString=JOptionPane.showInputDialog(null,
	 "Enter the taxable income:",
	 "Example 3.1 Input",JOptionPane.QUESTION_MESSAGE);
	 double income=Double.parseDouble(incomeString);

        // Compute tax
	double tax=0;

     if (status==0) {// Compute tax for single filers
	if(income<=6000)
	  tax=income * 0.10;
	else if (income<=27950)
	  tax=6000*0.10+(27950-6000)*0.15;
	else if (income <=67700)
	  tax=6000*0.10+(27950-6000)*0.15+(income-27950)*0.27;
	else if (income<= 141250)
	  tax = 6000*0.10+(27950-6000)*0.15+(67700-27950)*0.27+(income-67700)*0.30;
	else if (income<=307050)
	  tax = 6000*0.10+(27950-6000)*0.15+(67700-27950)*0.27+(141250-67700)*0.30+(income-141250)*0.35+(income-307050)*0.366;
	else
	  tax = 6000*0.10+(27950-6000)*0.15+(67700-27950)*0.27+(141250-67700)*0.30+(307050-141250)*0.35+(income-307050)*0.386;
	}
	else if (status==1) {// Compute tax for married file JOintly
	// 留给读者补充
	}
	else if (status==2) {// Compute tax for married separately
	// 留给读者补充
	}
	else if (status==3) {// Computer tax for head of household
	// 留给读者补充
	}
	else {
	System.out.println("Error;invalid status");
	System.exit(0);
	}

        //显示结果
	JOptionPane.showMessageDialog(null,"Tax is  "+(int)(tax*100)/100.0,"Example 3.1 Output",JOptionPane.INFORMATION_MESSAGE);
	}
 }
