Android个人所得税计算器

本人所做的Android个人所得税计算器程序。

先贴效果图:

所得税计算器

1、layout布局主要使用TableLayout,代码如下:

2、java实现,计算个税的方法很多,网上都有介绍,目前是按照9级税率的算法实现的,代码如下:

public class PersonalTax extends Activity {
	private static final String LOG_TAG = "PersonalTax";

	private TextView tvYanglaoNum, tvYiliaoNum, tvShiyeNum, tvZhufangNum;
	private EditText etShuiqianNum, etShuihouNum, etGeshui;
	private EditText etYanglao, etYiliao, etShiye, etZhufang;
	private EditText etShebaoBase, etYiliaoBase, etZhufangBase,
			etQizhengdianBase;
	private Button btnJisuan;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// setTitle("个税通——个人 所得税计算器");

		// 社保与住房公积金缴费金额
		tvYanglaoNum = (TextView) findViewById(R.id.tvYanglaoNum);
		tvYiliaoNum = (TextView) findViewById(R.id.tvYiliaoNum);
		tvShiyeNum = (TextView) findViewById(R.id.tvShiyeNum);
		tvZhufangNum = (TextView) findViewById(R.id.tvZhufangNum);

		// 税前税后以及个人 所得税金额
		etShuiqianNum = (EditText) findViewById(R.id.etShuiqianNum);
		etShuiqianNum.addTextChangedListener(new TextWatcher() {

			@Override
			public void afterTextChanged(Editable arg0) {
				// TODO Auto-generated method stub
				// 把输入内容同步显示在社保基数,医疗基数,住房公积金基数中
				etShebaoBase.setText(etShuiqianNum.getText());
				etYiliaoBase.setText(etShuiqianNum.getText());
				etZhufangBase.setText(etShuiqianNum.getText());
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onTextChanged(CharSequence s, int start, int before,
					int count) {
				// TODO Auto-generated method stub

			}

		});

		etShuihouNum = (EditText) findViewById(R.id.etShuihouNum);
		etGeshui = (EditText) findViewById(R.id.etGeshui);

		// 社保与住房公积金缴费比例
		etYanglao = (EditText) findViewById(R.id.etYanglao);
		etYiliao = (EditText) findViewById(R.id.etYiliao);
		etShiye = (EditText) findViewById(R.id.etShiye);
		etZhufang = (EditText) findViewById(R.id.etZhufang);

		// 社保与住房公积金缴费基数
		etShebaoBase = (EditText) findViewById(R.id.etShebaoBase);
		etYiliaoBase = (EditText) findViewById(R.id.etYiliaoBase);
		etZhufangBase = (EditText) findViewById(R.id.etZhufangBase);
		etQizhengdianBase = (EditText) findViewById(R.id.etQizhengdianBase);

		// 计算
		btnJisuan = (Button) findViewById(R.id.btnJisuan);
		btnJisuan.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// 计算个税
				String strShuiqian = etShuiqianNum.getText().toString();
				if (strShuiqian.length() <= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入税前收入!",="" toast.length_short).show();="" etshuiqiannum.requestfocus();="" return;="" }="" string="" stryanglao="etYanglao.getText().toString();" if="" (stryanglao.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入养老缴费比例!",="" toast.length_short).show();="" etyanglao.requestfocus();="" return;="" }="" string="" stryiliao="etYiliao.getText().toString();" if="" (stryiliao.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入医疗缴费比例!",="" toast.length_short).show();="" etyiliao.requestfocus();="" return;="" }="" string="" strshiye="etShiye.getText().toString().trim();" if="" (strshiye.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入失业缴费比例!",="" toast.length_short).show();="" etshiye.requestfocus();="" return;="" }="" string="" strzhufang="etZhufang.getText().toString();" if="" (strzhufang.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入住房公积金缴费比例!",="" toast.length_short).show();="" etzhufang.requestfocus();="" return;="" }="" string="" strshebaobase="etShebaoBase.getText().toString();" if="" (strshebaobase.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入社保缴费基数!",="" toast.length_short).show();="" etshebaobase.requestfocus();="" return;="" }="" string="" stryiliaobase="etYiliaoBase.getText().toString();" if="" (stryiliaobase.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入医疗缴费基数!",="" toast.length_short).show();="" etyiliaobase.requestfocus();="" return;="" }="" string="" strzhufangbase="etZhufangBase.getText().toString();" if="" (strzhufangbase.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入住房公积金缴费基数!",="" toast.length_short).show();="" etzhufangbase.requestfocus();="" return;="" }="" string="" strqizhengdianbase="etQizhengdianBase.getText()" .tostring();="" if="" (strqizhengdianbase.length()=""><= 0)="" {="" toast.maketext(getapplicationcontext(),="" "请输入个人="" 所得税起征点!",="" toast.length_short).show();="" etqizhengdianbase.requestfocus();="" return;="" }="" try="" {="" float="" shuiqiannum="Float.parseFloat(strShuiqian);" float="" yanglaonum="Float.parseFloat(strYanglao);" float="" yiliaonum="Float.parseFloat(strYiliao);" float="" shiyenum="Float.parseFloat(strShiye);" float="" zhufangnum="Float.parseFloat(strZhufang);" float="" shebaobase="Float.parseFloat(strShebaoBase);" float="" yiliaobase="Float.parseFloat(strYiliaoBase);" float="" zhufangbase="Float.parseFloat(strZhufangBase);" float="" qizhengdianbase="Float" .parsefloat(strqizhengdianbase);="" 养老缴纳金额="" float="" yanglao="shebaoBase" *="" yanglaonum="" *="" 0.01f;="" tvyanglaonum.settext(string.valueof(yanglao));="" 医疗缴纳金额="" float="" yiliao="yiliaoBase" *="" yiliaonum="" *="" 0.01f="" +="" 3;="" tvyiliaonum.settext(string.valueof(yiliao));="" 失业缴纳金额="" float="" shiye="shebaoBase" *="" shiyenum="" *="" 0.01f;="" tvshiyenum.settext(string.valueof(shiye));="" 住房公积金缴纳金额="" float="" zhufang="zhufangBase" *="" zhufangnum="" *="" 0.01f;="" tvzhufangnum.settext(string.valueof(zhufang));="" 计算个税="" float="" shuihou="shuiqianNum" -="" yanglao="" -="" yiliao="" -="" shiye="" -="" zhufang;="" float="" geshui="0f;" if="" (shuihou=""> qizhengdianBase) {
						// 需要交税
						float jiaoshuiBase = shuihou - qizhengdianBase;
						if (jiaoshuiBase <= 500)="" {="" geshui="jiaoshuiBase" *="" 0.05f;="" }="" else="" if="" (jiaoshuibase=""> 500 && jiaoshuiBase <= 2000)="" {="" geshui="jiaoshuiBase" *="" 0.1f="" -="" 25;="" }="" else="" if="" (jiaoshuibase=""> 2000 && jiaoshuiBase <= 5000)="" {="" geshui="jiaoshuiBase" *="" 0.15f="" -="" 125;="" }="" else="" if="" (jiaoshuibase=""> 5000 && jiaoshuiBase <= 20000)="" {="" geshui="jiaoshuiBase" *="" 0.2f="" -="" 375;="" }="" else="" if="" (jiaoshuibase=""> 20000
								&& jiaoshuiBase <= 40000)="" {="" geshui="jiaoshuiBase" *="" 0.25f="" -="" 1375;="" }="" else="" if="" (jiaoshuibase=""> 40000
								&& jiaoshuiBase <= 60000)="" {="" geshui="jiaoshuiBase" *="" 0.3f="" -="" 3375;="" }="" else="" if="" (jiaoshuibase=""> 60000
								&& jiaoshuiBase <= 80000)="" {="" geshui="jiaoshuiBase" *="" 0.35f="" -="" 6375;="" }="" else="" if="" (jiaoshuibase=""> 80000
								&& jiaoshuiBase <= 100000)="" {="" geshui="jiaoshuiBase" *="" 0.4f="" -="" 10375;="" }="" else="" if="" (jiaoshuibase=""> 100000) {
							geshui = jiaoshuiBase * 0.45f - 15375;
						}
					}
					shuihou -= geshui;
					if (shuihou < 0f)="" {="" toast.maketext(getapplicationcontext(),="" "税后收入为负数,请检查输入是否正确!",="" toast.length_short)="" .show();="" etshuihounum.settextcolor(color.red);="" }="" else="" {="" etshuihounum.settextcolor(color.blue);="" }="" etshuihounum.settext(string.valueof(shuihou));="" etgeshui.settext(string.valueof(geshui));="" }="" catch="" (exception="" e)="" {="" e.printstacktrace();="" log.e(log_tag,="" "parsefloat="" error!!!");="" }="" }="" });="" }="" }="">
暂无评论
  • 1:请一针见血的评论。
  • 2:评论需要审核通过后才能显示。
  • 3:评论字数限制在1000字以内。
  • 当前字数:0
热门文章
推荐文章
随机文章
关于本站 - 广告服务 - 版权声明 - 联系我们 - 友情链接 - 网站地图 - 帮助中心