Advertisement
selvalives

Untitled

Aug 30th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. package com.nsu.hpcalc;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.EditText;
  8. import android.widget.TextView;
  9.  
  10. public class calcactivity extends Activity
  11. {
  12. EditText tcarprice,tinterest,tdownpayment,tyears;
  13. TextView tinstallment;
  14. Button btncalc;
  15. public void onCreate(Bundle b)
  16. {
  17. super.onCreate(b);
  18. setContentView(R.layout.calclayout);
  19. tcarprice=findViewById(R.id.tcarprice);
  20. tinterest=findViewById(R.id.tinterest);
  21. tdownpayment=findViewById(R.id.tdownpayment);
  22. tinstallment=findViewById(R.id.tinstallment);
  23. tyears=findViewById(R.id.tyears);
  24. btncalc=findViewById(R.id.btncalculate);
  25. btncalc.setOnClickListener(new View.OnClickListener() {
  26. @Override
  27. public void onClick(View v) {
  28. double carprice,interest,downpayment,installment;
  29. int years;
  30. carprice=Double.parseDouble(tcarprice.getText().toString());
  31. interest=Double.parseDouble(tinterest.getText().toString());
  32. downpayment=Double.parseDouble(tdownpayment.getText().toString());
  33. years=Integer.parseInt(tyears.getText().toString());
  34. installment=(((((carprice-downpayment)*interest)/100)*years)+(carprice-downpayment))/(years*12);
  35. tinstallment.setText(String.valueOf(installment));
  36. }
  37. });
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement