Currently I have the dilemma that I want to do a certain operation with different basic math signs (add, subtract, multiply etc.). But I want the sign to be the only one that changes when doing the operation:
Previous code
resultado = resultado + numero; // Este código me daba el resultado de la suma de ambos números
Current code:
resultado = resultado +operadores+ numero; // este código me marca error
The line that marks me error is to what is due, I'm putting a string of text inside a variable of type int with two variables that are also whole, what I wanted to do is replace the "+" that made me the sum for another "+ o - o * o /" through the assignment to a variable and that depending on the selected button this would send me the necessary operator. The truth is I do not know if I am developing it in the best way but it is the only one that occurred to me at the moment and I wanted to see if I was able to do what I am trying to do. if I convert it to a string, the result variable will print everything and will not give me any resulting number.
Complete code of the method
public void igualdad(View v) {
TextView txtSI = (TextView) findViewById(R.id.txtView);
obtenerNS = txtSI.getText().toString().split("\+");
for (int i = 0; i < obtenerNS.length; i++) {
int numero = Integer.parseInt(obtenerNS[i].trim());
resultado = resultado +operadores+ numero;
}
txtSI.setText("");
txtSI.setText(String.valueOf(resultado));
}