The last condition fails verification. Recommendation from the mentor is:
Addition problems are not solved correctly.
See screenshot below
How do I fix this?

package com.codegym.task.task19.task1914;
/*
Problem solving
*/
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream consoleStream = System.out;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(outputStream);
System.setOut(stream);
testString.printSomething(); //This line will print to the ByteArrayOutputStream and not the console.
System.setOut(consoleStream); //Restore the original consoleStream.
//Remove all spaces from the streamResult string.
String streamResult = outputStream.toString();
ArrayList<String> digitString = new ArrayList<>();
//Get all the numbers from the streamResult (outputstream)
while (true) {
if (streamResult.length() == 0) break;
digitString.add(streamResult.substring(0, streamResult.indexOf(" ")));
streamResult = streamResult.substring(streamResult.indexOf(" ") + 3);
}
//Get all the operators and store in the operators string
String operators = "";
for (int i : outputStream.toByteArray()) {
if (i == 42 || i == 43 || i == 45)
operators += (char) i;
}
//Get the first number from the digitString list
double finalResult = Double.parseDouble(digitString.get(0));
//Perform the operation with the finalResult and the next number.
//The next number is always at index i+1
for (int i = 0; i < operators.length(); i++) {
if ("+".equals(String.valueOf(operators.charAt(i))))
finalResult += Double.parseDouble(digitString.get(i+1));
else if ("-".equals(String.valueOf(operators.charAt(i))))
finalResult -= Double.parseDouble(digitString.get(i+1));
else if ("*".equals(String.valueOf(operators.charAt(i))))
finalResult *= Double.parseDouble(digitString.get(i+1));
}
//Now print out the result of the operation and round up finalResult
System.out.println(outputStream.toString() + Math.round(finalResult));
}
public static class TestString {
public void printSomething() {
System.out.print("3 + 6 = ");
}
}
}