I have an issue with the following condition:
if (Cuadrado.isChecked() == true)
This is the full code:
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
String dato5 = DatoMath.getText().toString();
if (Cubo.isChecked()==true) {
if (dato5.equals("")) {
Toast toast = Toast.makeText(getApplicationContext(), "no hay datos", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER | Gravity.LEFT, 0, 0);
toast.show();
} else {
int datofinal = Integer.parseInt(dato5);
int final3 = (int) Math.pow(datofinal, 2);
Resultado.setText("" + final3);};
if (Cuadrado.isChecked() == true) {
if (dato5.equals("")) {
Toast toast = Toast.makeText(getApplicationContext(), "no hay datossssss", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0);
toast.show();
} else {
int datofinal2 = Integer.parseInt(dato5);
int final4 = (int) Math.pow(datofinal2, 3);
Resultado.setText("" + final4);
};
Why are you intentionally complicating your code, you can simply write:
The isChecked method returns a boolean so you can directly write it inside that if condition
And one more thing, why have you put a semi-colon[ ; ] after your else statements closing brace[ } ], replace that semicolon with another closing brace[ } ]