KEMBAR78
Salary Tax | PDF | Php | Computing
0% found this document useful (0 votes)
5 views6 pages

Salary Tax

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Salary Tax

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

 Salary Tax (Android)

-MainAc�vity
public class MainActivity extends AppCompatActivity {
CheckBox Salary_Tax;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Salary_Tax = (CheckBox) findViewById(R.id.chSalary);


salaryTax();
}
private void salaryTax(){
Salary_Tax.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent openSalaryTax = new Intent(MainActivity.this,
com.example.mobileapp.Salary_Tax.class);
startActivity(openSalaryTax);
}
});
}
}
-Salary_Tax
public class Salary_Tax extends AppCompatActivity {
EditText gross;
Button btnOK;
TextView textNet;
TextView textTak;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_salary_tax);

gross = (EditText) findViewById(R.id.edGross);


textTak = (TextView) findViewById(R.id.txtTak);
textNet = (TextView) findViewById(R.id.txtNet);
btnOK = (Button) findViewById(R.id.btnOK);

btnOK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
double grossSalary, netSalary = 0, tax = 0;
Salary_Class ob = new Salary_Class();

grossSalary =
Double.parseDouble(gross.getText().toString());
tax = ob.Tak(grossSalary);

netSalary = ob.netSalary(grossSalary, tax);


textTak.setText("Tax: " + Double.toString(tax) + "R");
textNet.setText("Net Salary: " + Double.toString(netSalary)
+ "R");
}
});
}
}
-Salary_Class
public class Salary_Class {
double Tak(double grossSalary){
double tak = 0;

if ((grossSalary >= 0) && (grossSalary <= 150000)){


tak = 0;
}else if((grossSalary > 150000) && (grossSalary <= 200000)){
tak = (grossSalary * 0.05) - 75000;
} else if ((grossSalary > 200000) && (grossSalary <= 850000)) {
tak = (grossSalary * 0.1) - 175000;
} else if ((grossSalary > 850000) && (grossSalary <= 12500000)) {
tak = (grossSalary * 0.15) - 600000;
} else if ((grossSalary > 12500000)) {
tak = (grossSalary * 0.2) - 1125000;
}
return tak;
}
double netSalary (double grossSalary, double tak){
return grossSalary - tak;
}
}
 Score Manangment

-MainAc�vity
public class MainActivity extends AppCompatActivity {

EditText edHtml, edJava, edCshap, edphp, edMysql;


TextView textTotal, textAvg, textGrade;
Button btnOK;

@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

edHtml = (EditText) findViewById(R.id.txtHTML);


edJava = (EditText) findViewById(R.id.txtJava);
edCshap = (EditText) findViewById(R.id.txtCShap);
edphp = (EditText) findViewById(R.id.txtPHP);
edMysql = (EditText) findViewById(R.id.txtMySQL);
textTotal = (TextView) findViewById(R.id.textTotal);
textAvg = (TextView) findViewById(R.id.textAvg);
textGrade = (TextView) findViewById(R.id.textGrade);
btnOK = (Button) findViewById(R.id.btnOK);
score();
}

private void score() {


btnOK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
double html, java, cshap, php, mysql, totalScore = 0,
avgScore = 0;
String grade = "";

html = Double.parseDouble(edHtml.getText().toString());
java = Double.parseDouble(edJava.getText().toString());
cshap = Double.parseDouble(edCshap.getText().toString());
php = Double.parseDouble(edphp.getText().toString());
mysql = Double.parseDouble(edMysql.getText().toString());

ImplementMainFun ob = new ImplementMainFun();


totalScore = ob.totalScore(html, java, cshap, php, mysql);
avgScore = ob.avgScore(totalScore, 5);
grade = ob.grade(avgScore);

textTotal.setText("Total Score: " +


Double.toString(totalScore));
textAvg.setText("Avg Score: " + Double.toString(avgScore) +
"%");
textGrade.setText("Grade: " + grade);
}
});
}
}
-ImplementmainFun
public class ImplementMainFun implements MainFun {

@Override
public double totalScore(double html, double java, double cShap, double
mysql, double php) {
return html + java + cShap + php + mysql;
}

@Override
public double avgScore(double totalScore, int sumNum) {
return totalScore/sumNum;
}

@Override
public String grade(double avgScore) {
String result = "";
if ((avgScore >= 0) && (avgScore < 50)) {
result = "F";
} else if ((avgScore >= 50) && (avgScore < 60)) {
result = "E";
} else if ((avgScore >= 60) && (avgScore < 70)) {
result = "D";
} else if ((avgScore >= 70) && (avgScore < 80)) {
result = "C";
} else if ((avgScore >= 80) && (avgScore < 90)) {
result = "B";
} else if ((avgScore >= 90) && (avgScore <= 100)) {
result = "A";
}else {
result = "Invalid grade";
}
return result;
}
}
-MainFun
public interface MainFun {
double totalScore (double html, double java, double cShap, double
mysql, double php);

double avgScore (double totalScore , int sumNum);


String grade (double avgScore);
}

You might also like