[Solved] How can I get the sum, difference, quotient, product of two values and printed out in textview [closed]


add two EditText for getting two numbers then add four button for different operation like add/sub/mul/div. Get value of editText and Set onClickListener and write appropriate code in that.

EditText firstNumber;
EditText secondNumber;
TextView addResult;
Button btnAdd;

double num1,num2,sum;

firstNumber = (EditText)findViewById(R.id.txtNumber1);
secondNumber = (EditText)findViewById(R.id.txtNumber2);
addResult = (TextView)findViewById(R.id.txtResult);
btnAdd = (Button)findViewById(R.id.btnAdd);

btnAdd.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        num1 = Double.parseDouble(firstNumber.getText().toString());
        num2 = Double.parseDouble(secondNumber.getText().toString());
        sum = num1 + num2;
        addResult.setText(Double.toString(sum));
    }
});

something like that.

8

solved How can I get the sum, difference, quotient, product of two values and printed out in textview [closed]