Skip to main content

Posts

Showing posts with the label math

MathML and Java

I've been doing some research for a mathematical Android related project I'd like to embark upon and I stumbled across for the first time MathML.

Android - calculating and storing the answer of an arithmetic expression

What would be best way to get the answer to this question which is using random numbers and random operators. editTextEquation.setText(random1 +(String.valueOf(ops[i1]) + random2 + (String.valueOf(ops[i2])+ random3 + (String.valueOf(ops[i3])+ random4)))); I'm displaying this question and then will check the answer against user input. I'm guessing I'd need to store the answer first. Any help/advice will be very much appreciated. Here is how I am generating the expression: int random1 = (int)(Math.random()*100); int random2 = (int)(Math.random()*100); int random3 = (int)(Math.random()*200); int random4 = (int)(Math.random()*20); int min = 0; int max = 3; Random r = new Random(); int i1 = r.nextInt(max - min); int i2 = r.nextInt(max - min); int i3 = r.nextInt(max - min); char[] ops = { '+', '-', '/', '*' }; int answer;