Что делаю не так? Проверял, все 3 варианта работает, но не принимает.
package com.javarush.task.task19.task1914;
/*
Решаем пример
*/
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream printStream = System.out;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(byteArrayOutputStream);
System.setOut(stream);
testString.printSomething();
String s = byteArrayOutputStream.toString();
char [] chars = s.toCharArray();
int a = Character.getNumericValue(chars[0]);
int b = Character.getNumericValue(chars[4]);
int c = 0;
switch (chars[2]){
case '+' : c = a + b; break;
case '-' : c = a - b; break;
case '*' : c = a * b; break;
}
System.setOut(printStream);
System.out.println( a + " " +chars[2]+ " "+ b + " = " + c );
}
public static class TestString {
public void printSomething() {
System.out.println("3 + 6 = ");
}
}
}