How can we get one value back of two values? For example, if the user writes 100, how can we replace 100 with 50+50 in the text box? That is, suppose the user types 100 and on pressing the button, instead of 100, the text box should show 50+50 or 75+25 and so on، which is equal to 100 .A friend suggest me but I want to provide a low and a high value to the user. That is, if the user writes 100, it should be displayed as 75+25 or 80+20 etc. Thanks
int customerInput = 100; //getvalue from user
int splitValue = customerInput/2;
saif.setText(splitValue+"+"+splitValue);
>Solution :
What are the lows and highs that you need?
In your example it’s 1/4 and 3/4 so that would give you:
int customerInput = 100; //getvalue from user
int splitValue1 = customerInput/4;
int splitValue2 = (customerInput/4)*3;
saif.setText(splitValue+"+"+splitValue);
If you need it to be random you can use the Java function
int random = Random.nextInt(n)
This returns a random int in the range [0, n-1].
So in your case you would need a random number between 0 and 100
int customerInput = 100; //getvalue from user
int random = new Random().nextInt(100); // [0, 100]
int random2 = 100 - random; // the other percent of your number
saif.setText(random+"+"+random2);