Posted on 2007-04-08 12:05
停留的风 阅读(475)
评论(0) 编辑 收藏 所属分类:
Java程序集合
import javax.swing.JOptionPane;
public class taxQuestion
{
public static void main(String[] args)
{
//输入基准值
String statusString=JOptionPane.showInputDialog(null,"Enter the filing status:\n"+"(0-single filer,1-married jointly,\n)"+"2-married separately,3-head of household)","Input a status",JOptionPane.QUESTION_MESSAGE);
int status=Integer.parseInt(statusString);
//输入收入値
String incomeString=JOptionPane.showInputDialog(null,"Enter the taxable income:","Give me your money",JOptionPane.QUESTION_MESSAGE);
Double income=Double.parseDouble(incomeString);
double tax=0;
if(status==0)
{
if(income<=1200)
JOptionPane.showMessageDialog(null,"You should not pay for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
else if(income<=3000)
{
tax=(income-1200)*0.10;
JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
}
else if(income<=10000)
{
tax=(income-3000)*0.15;
JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
}
else if(income<300000)
{
tax=(income-10000)*0.30;
JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
}
else
{
tax=(income-300000)*0.80;
JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
}
}
else
{
tax=(income-status);
JOptionPane.showMessageDialog(null,"You should pay"+tax+"for the tax!","The show of the result",JOptionPane.INFORMATION_MESSAGE);
}
}
}
/////////////////////////////////////////////////////////////////////////
测试结果简要如下:
////////////////////////////////////////////////////////////////////////