0

I have a series of string which are read in via a BufferReader as below.

And at each point mathematical expressions are added to an array-list, I would like, to be able to evaluate these expressions within Android but currently I don't know how

i.e. I would like to be able to say as a result of the calcilation expressionList.get(0) = 1.92 etc.

I would like to accomplish this, without the use of additional code libraries.

Examples of read in expressions:

    "(((10 + 9.2)/50) *5)"
    "((3 - 1.2)*20)"
    "51 * 100"
    "2 / 132"
    etc.

My code:

          ArrayList<String> expressionList = new ArrayList<>();
          FileInputStream is = new FileInputStream(fileLocation);
          BufferedReader  reader = new BufferedReader(new InputStreamReader(is));

            String line = reader.readLine();
            while (line != null) {
            line = reader.readLine();
            if (line.contains("/") || line.contains("*") || line.contains("+") || line.contains("-")){
            expressionList.add(line);
}
            }

0 Answers0