How to open an activity from a calculation?

0

I'm a layman in android studio and need to do a program on a BMI calculation. The idea is simple, in the first activity he asks for his weight and his height, after that he must make the account of the imc (imc = weight / height²) and if the result is smaller than 20 it opens an activity, if it is greater than 30 it opens another and if it is between 20 and 30 it opens a 4th activity. Can someone help me with this function?

    
asked by anonymous 23.09.2017 / 20:38

1 answer

1

Only use if with the result of the account:

    double imc = peso / Math.pow(altura,2)
if (imc <20 ){
Intent tela1 = new Intent(getApplicationContext(), tela1.class);
            startActivity(tela1);
}else if(imc > 30 ){
Intent tela2 = new Intent(getApplicationContext(), tela2.class);
            startActivity(tela2);
}else if(imc>=20 && imc <=30){
Intent tela3 = new Intent(getApplicationContext(), tela3.class);
            startActivity(tela3);
}

This within the click of the calculate button. The logic is this, I hope I have helped

    
23.09.2017 / 21:10