Back to project page TaxCalculatorAndroid.
The source code is released under:
Copyright (c) Agiliq Info Solutions India Pvt. Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following con...
If you think the Android project TaxCalculatorAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.agiliq.taxcalc; /* w ww .j a v a 2 s . c om*/ import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import java.lang.Math; import com.agiliq.taxcalcpro.R; import com.flurry.android.FlurryAgent; public class TaxCalculator extends Activity implements Button.OnClickListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); System.out.println("10"); setContentView(R.layout.main); } public void onStart() { super.onStart(); FlurryAgent.onStartSession(this, "GSYR3HKPHK9Y5242RPBQ"); } public void onClick(View v){ EditText income = (EditText)findViewById(R.id.income); EditText investments = (EditText)findViewById(R.id.investments); EditText infraInvestments = (EditText)findViewById(R.id.infraInvestment); EditText housingInterest = (EditText)findViewById(R.id.housingInterest); EditText medicalPremium = (EditText)findViewById(R.id.medicalPremium); TextView calculatedTax = (TextView)findViewById(R.id.calculated_tax); int income_i, investments_i, infraInvestments_i; int housingInterest_i, medicalPremium_i; try{ income_i = Integer.parseInt(income.getText().toString()); } catch (NumberFormatException e) { income_i = 0; } try { investments_i = Integer.parseInt(investments.getText().toString()); } catch (NumberFormatException e) { investments_i = 0; } try { infraInvestments_i = Integer.parseInt(infraInvestments.getText().toString()); } catch (NumberFormatException e) { infraInvestments_i = 0; } try { housingInterest_i = Integer.parseInt(housingInterest.getText().toString()); } catch (NumberFormatException e) { housingInterest_i = 0; } try { medicalPremium_i = Integer.parseInt(medicalPremium.getText().toString()); } catch (NumberFormatException e) { medicalPremium_i = 0; } int final_tax = calculateTax(income_i, investments_i, infraInvestments_i, housingInterest_i, medicalPremium_i); calculatedTax.setText("" + final_tax); TextView taxBottom = (TextView)findViewById(R.id.taxBot); taxBottom.setText(""+final_tax); } public int calculateTax(int income, int investments, int infraInvestments, int housingInterest, int medicalPremium){ investments = Math.max(0, Math.min(investments, 100000)); infraInvestments = Math.max(0, Math.min(infraInvestments, 20000)); housingInterest = Math.max(0, Math.min(housingInterest, 15000)); medicalPremium = Math.max(0, Math.min(medicalPremium, 35000)); int taxableIncome = income - (investments+infraInvestments+housingInterest+medicalPremium); return (int)getTax(taxableIncome); } public double getTax(int taxableIncome){ double taxOnThisSlab; if (taxableIncome < 160000) { return 0; } else if (taxableIncome < 500000){ taxOnThisSlab = 0.1 * (taxableIncome - 160000); return taxOnThisSlab; } else if (taxableIncome < 800000){ taxOnThisSlab = 0.2 * (taxableIncome - 500000); return taxOnThisSlab + 34000; } else { taxOnThisSlab = 0.3 * (taxableIncome - 800000); return taxOnThisSlab + 94000; } } public void onStop() { super.onStop(); FlurryAgent.onEndSession(this); } }