You are on page 1of 15

EMI ACTIVITY

package com.cmt.taxcalculator;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class EMIActivity extends AppCompatActivity {

Button emiCalcBtn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emi);

final EditText P = findViewById(R.id.principal);


final EditText I = findViewById(R.id.interest);
final EditText Y = findViewById(R.id.years);
final EditText TI = findViewById(R.id.interest_total);
final EditText result = findViewById(R.id.emi) ;

emiCalcBtn = findViewById(R.id.btn_calculate2);

emiCalcBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String st1 = P.getText().toString();


String st2 = I.getText().toString();
String st3 = Y.getText().toString();

if (TextUtils.isEmpty(st1)) {
P.setError("Enter Principal Amount");
P.requestFocus();
return;
}

if (TextUtils.isEmpty(st2)) {
I.setError("Enter Interest Rate");
I.requestFocus();
return;
}

if (TextUtils.isEmpty(st3)) {
Y.setError("Enter Years");
Y.requestFocus();
return;
}

float p = Float.parseFloat(st1);
float i = Float.parseFloat(st2);
float y = Float.parseFloat(st3);
float Principal = calPric(p);

float Rate = calInt(i);

float Months = calMonth(y);

float Dvdnt = calDvdnt( Rate, Months);

float FD = calFinalDvdnt (Principal, Rate, Dvdnt);

float D = calDivider(Dvdnt);

float emi = calEmi(FD, D);

float TA = calTa (emi, Months);

float ti = calTotalInt(TA, Principal);

result.setText(String.valueOf(emi));

TI.setText(String.valueOf(ti));

}
});
}

public float calPric(float p) {

return (p);

public float calInt(float i) {

return (i/12/100);

public float calMonth(float y) {

return (y * 12);

public float calDvdnt(float Rate, float Months) {

return (float) ((1+Rate)* Months);

public float calFinalDvdnt(float Principal, float Rate, float Dvdnt) {

return (Principal * Rate * Dvdnt);

public float calDivider(float Dvdnt) {

return (Dvdnt-1);
}

public float calEmi(float FD, Float D) {

return (FD/D);

public float calTa(float emi, Float Months) {

return (emi*Months);

public float calTotalInt(float TA, float Principal) {

return (TA - Principal);

}
}

Final Income Accounts

package com.cmt.taxcalculator;

import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class FinalIncomeActivity extends AppCompatActivity {


TextView T1,T2,T3,T4,T5,T6,T7;
Button back,backmain;
String base,LTA,HRA,SA, A,B,C;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_final_income);
back=(Button)findViewById(R.id.goback);
backmain=(Button)findViewById(R.id.backtomain);
backmain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new
Intent(FinalIncomeActivity.this,MainActivity.class);
startActivity(i);
}
});
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i=new
Intent(FinalIncomeActivity.this,IncomeActivity.class);
startActivity(i);
}
});
T1=(TextView)findViewById(R.id.t1);

T2=(TextView)findViewById(R.id.t2);

T3=(TextView)findViewById(R.id.t3);

T4=(TextView)findViewById(R.id.t4);

T6=(TextView)findViewById(R.id.t6);

T7=(TextView)findViewById(R.id.t7);
Intent i=getIntent();
HRA=i.getStringExtra("hra");
LTA=i.getStringExtra("lta");
base=i.getStringExtra("base");
SA=i.getStringExtra("sa");
A=i.getStringExtra("80A");
B=i.getStringExtra("80B");
C=i.getStringExtra("80C");
int baseInt=Integer.parseInt(base);
double HRAdouble=Double.parseDouble(HRA);
double LTAdouble=Double.parseDouble(LTA);
double SAdouble=Double.parseDouble(SA);
double Adouble=Double.parseDouble(A);
double Bdouble=Double.parseDouble(B);
double Cdouble=Double.parseDouble(C);
double totalIncome=baseInt+HRAdouble+LTAdouble+SAdouble;
T1.setText(base);
int forT2=(int)HRAdouble+(int)LTAdouble+(int)SAdouble;
T2.setText(""+forT2);
int totalG=baseInt+(int)HRAdouble+(int)LTAdouble+(int)SAdouble;
T3.setText(""+totalG);
double ded= (int)Adouble+(int)Bdouble+(int)Cdouble;
T4.setText(""+ded);

double grossdeduction=ded+50000;
int totaltaxable=(int)totalIncome-(int)grossdeduction;
T6.setText(""+totaltaxable);
double tax=0;
if(totaltaxable<250000){
tax=0;
}else if(totaltaxable>250000 && totaltaxable<500000){
tax=0.05*totaltaxable;

}
else if(totaltaxable>500000 && totaltaxable<1000000){
tax=0.20*totaltaxable;
}
else if(totaltaxable>1000000){
tax=0.30*totaltaxable;
}
T7.setText("Total Tax: "+tax );

}
}
GST Activity
package com.cmt.taxcalculator;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class GSTActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emi);

}
}

Incomeactivity

package com.cmt.taxcalculator;

import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class IncomeActivity extends AppCompatActivity {

EditText bs;
EditText hra;
EditText sa;
EditText lta;
TextView T1,T2,T3,T4,T5;
TextView tx;
TextView tx1;
Button b1;
Button con;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_income);
con=(Button)findViewById(R.id.next);
bs=findViewById(R.id.edit1);
hra=findViewById(R.id.edit2);
sa=findViewById(R.id.edit3);
lta=findViewById(R.id.edit4);
T1=findViewById(R.id.t1);
T2=findViewById(R.id.t2);
T3=findViewById(R.id.t3);
T4=findViewById(R.id.t4);
T5=findViewById(R.id.t5);
tx1=findViewById(R.id.text3);
b1=findViewById(R.id.go);
con.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
calculate();
}
});
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

try {
int HRA=Integer.parseInt(hra.getText().toString());
int LTAc=Integer.parseInt(lta.getText().toString());
double calcHRA=0.36*HRA;
double calcLTA=0.12*LTAc;

T1.setText(""+bs.getText().toString());
T2.setText(""+calcHRA);
T3.setText(""+sa.getText().toString());
T4.setText(""+calcLTA);
T5.setText(""+50000);
con.setEnabled(true);

}
catch (Exception e) {
Toast.makeText(getApplicationContext(), "An Error
Occurred, Please try again!", Toast.LENGTH_LONG).show();

}
}
});
}

public void calculate()


{
Intent i=new Intent(IncomeActivity.this,NextIncome.class);
i.putExtra("baseincome",bs.getText().toString());
i.putExtra("HRA",T2.getText().toString());
i.putExtra("SA",sa.getText().toString());
i.putExtra("LTA",lta.getText().toString());
startActivity(i);

}
}

Mainactivity

package com.cmt.taxcalculator;

import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {


TextView t;
Button b1;
Button b2;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);// To Display The Layout from
activy_main resource layout file.
setContentView(R.layout.activity_main);
b1 = findViewById(R.id.button1);
b2 = findViewById(R.id.button2);

b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent= new Intent(MainActivity.this,
com.cmt.taxcalculator.IncomeActivity.class);
startActivity(intent); // On clicking on the button, Income
Tax Calculator activity is called
}
});

b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(MainActivity.this,
com.cmt.taxcalculator.EMIActivity.class);
startActivity(intent);// On clicking on the button, EMI
activity is called
}
});
}

public void exitApp() {


finish();
}

Nextincome

package com.cmt.taxcalculator;

import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class NextIncome extends AppCompatActivity {


Button go;
EditText e1,e2,e3;
String base,LTA,HRA,SA;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next_income);
e1=(EditText)findViewById(R.id.edit1);
e2=(EditText)findViewById(R.id.edit2);
e3=(EditText)findViewById(R.id.edit3);
Intent i=getIntent();
base=i.getStringExtra("baseincome");
LTA=i.getStringExtra("LTA");
HRA=i.getStringExtra("HRA");
SA=i.getStringExtra("SA");

go=(Button)findViewById(R.id.go);
go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});

}
public void finish(){
double A=Double.parseDouble(e1.getText().toString());
double B=Double.parseDouble(e2.getText().toString());
double C=Double.parseDouble(e3.getText().toString());
Intent i=new Intent(NextIncome.this,FinalIncomeActivity.class);
i.putExtra("80A",e1.getText().toString());
i.putExtra("base",base);
i.putExtra("hra",HRA);
i.putExtra("lta",LTA);
i.putExtra("sa",SA);
i.putExtra("80B",e2.getText().toString());
i.putExtra("80C",e3.getText().toString());
startActivity(i);

}
}

SplashScreen

package com.cmt.taxcalculator;

import android.content.Intent;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class SplashScreen extends AppCompatActivity {

private static int SPLASH_TIMEOUT=2000;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent= new Intent(SplashScreen.this,
MainActivity.class);
startActivity(intent);
finish();
}
},SPLASH_TIMEOUT);
}
}

Example instructions

package com.cmt.taxcalculator;

import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing
documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.cmt.taxcalculator", appContext.getPackageName());
}
}

EMI Activity test

package com.cmt.taxcalculator;

import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
/**
* Example local unit test, which will execute on the development machine
(host).
*
* @see <a href="http://d.android.com/tools/testing">Testing
documentation</a>
*/

public class EMIActivityTest {

@Test
public void calPric_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(5.12f, Test.calPric(5.12f), 0.01);
assertNotEquals(5.1f, Test.calPric(5.12f), 0.01);

@Test
public void calInt_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(0.01f, Test.calInt(12.0f), 0.00001);
assertNotEquals(0.01f, Test.calInt(11.0f), 0.00001);

@Test
public void calMonth_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(1.2f, Test.calMonth(0.1f), 0.00001);
assertNotEquals(1.2f, Test.calMonth(0.2f), 0.00001);

@Test
public void calDvdnt_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(1.159693f, Test.calDvdnt(0.025f, 6.0f), 0.000001);
assertNotEquals(1.159692f, Test.calDvdnt(0.025f, 6.0f), 0.000001);

@Test
public void calFinalDvdnt_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(1508.0f, Test.calFinalDvdnt(52000.0f, 0.025f, 1.16f),
0.1);
assertNotEquals(1509.0f, Test.calFinalDvdnt(52000.0f, 0.025f,
1.16f), 0.1);

@Test
public void calDivider_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(0.16f, Test.calDivider(1.16f), 0.001);
assertNotEquals(0.15f, Test.calDivider(1.16f), 0.001);
}

@Test
public void calEmi_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(768.0f, Test.calEmi(19.2f, 0.025f), 0.001);
assertNotEquals(768.1f, Test.calEmi(19.2f, 0.025f), 0.001);

@Test
public void calTa_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(4608.0f, Test.calTa(768.0f, 6.0f), 0.001);
assertNotEquals(4609.1f, Test.calTa(768.0f, 6.0f), 0.001);

@Test
public void calTotalInt_isCorrect(){

EMIActivity Test = new EMIActivity();


assertEquals(-5392.0f, Test.calTotalInt(4608.0f, 10000.0f), 0.001);
assertNotEquals(5392.0f, Test.calTotalInt(4608.0f, 10000.0f),
0.001);

<?xml version="1.0" encoding="utf-8"?>


<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37
70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61
76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45
35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81
38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71
60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81
71.71,38.56C72.44,39.3 72.44,40.45
71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76
64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01
61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01
47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76
43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.cmt.taxcalculator">

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".FinalIncomeActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
></activity>
<activity android:name=".NextIncome" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=".IncomeActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
<activity android:name=".SplashScreen" />
<activity android:name=".EMIActivity" />
</application>

</manifest>

You might also like