androidandroid-studioandroid-studio-2.1

how do I define the or condition in android studio


I'm new to programming and I am making a new simple app, but I'm struggling with something.

The app I'm making is a sort of calculator.

This is what it looks like

So what is does now is you type a percentage and a number in and it gives you the answer when you press the calculate button(Bereken), but now I want it to give me the percentage when I type something in the answer textview and the number textview.

I think that I have to make an "or" condition studio. I know that in Java you can use || to define "or", but how does it work in Android studio?


Solution

  • OR Condition works like this:

    int x=5;
    if(x=5 || x=10){
    System.out.println("OR Condition passed");
    }
    

    Sample code:

    int answer= Integer.parseInt(answerEditText.getText().toString());
    int number= Integer.parseInt(numberEditext.getText().toString());
    

    Use the reverse of the below formula to get the percentage from answer and number.

    int k = (int)(value*(percentage/100.0f));