Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nsu.hpcalc;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class calcactivity extends Activity
- {
- EditText tcarprice,tinterest,tdownpayment,tyears;
- TextView tinstallment;
- Button btncalc;
- public void onCreate(Bundle b)
- {
- super.onCreate(b);
- setContentView(R.layout.calclayout);
- tcarprice=findViewById(R.id.tcarprice);
- tinterest=findViewById(R.id.tinterest);
- tdownpayment=findViewById(R.id.tdownpayment);
- tinstallment=findViewById(R.id.tinstallment);
- tyears=findViewById(R.id.tyears);
- btncalc=findViewById(R.id.btncalculate);
- btncalc.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- double carprice,interest,downpayment,installment;
- int years;
- carprice=Double.parseDouble(tcarprice.getText().toString());
- interest=Double.parseDouble(tinterest.getText().toString());
- downpayment=Double.parseDouble(tdownpayment.getText().toString());
- years=Integer.parseInt(tyears.getText().toString());
- installment=(((((carprice-downpayment)*interest)/100)*years)+(carprice-downpayment))/(years*12);
- tinstallment.setText(String.valueOf(installment));
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement