In short i have a method which selects a random operation and generates two random numbers, it then creates an expression out of them as a string and changes a textview to show that expression as show here:
public String Nov2()
{
String[] ops = new String[] {" + ", " - ", " * ", " / "};
int i = rand.nextInt(4-0) + 0;
String op1 = ops[i];
int novnum1 = rand.nextInt(101-1) + 1;
int novnum2 = rand.nextInt(101-1) + 1;
String nov2Exp = novnum1 + op1 + novnum2 + " = ";
setContentView(R.layout.gameview);
TextView display = (TextView) findViewById(R.id.exp);
display.setText(nov2Exp);
return nov2Exp;
}
I have a second method which will put a number as a string into a second textview depending on which button is pressed:
@Override
public void onClick(View c) {
switch (c.getId())
{
case R.id.keypad_1:
TextView prs1 = (TextView) findViewById(R.id.ans);
if (prs1.getText().equals("?"))
{
prs1.setText("1");
}
else
{
prs1.append("1");
}
break;
What i need is that when the user pushes another button the answer to expression will be calculated and compared with the contents of the answer textview, i’ve done some research on maths expression parsing and its proving far too complex for me to implement. Would i need to somehow return mutliple variables of different types from my method or am completely wrong? Can anyone help me?

You can define a custom data type:
and have your method return an object of this type.
Edit:
Well you can do something like:
This method will generate you a new expression, put it on the screen and then return the result. You can store it somewhere and when the user clicks the button compare it with his input.