?
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 console = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
System.setOut(ps);
testString.printSomething();
System.setOut(console);
String res = baos.toString();
String[] resArray = res.split(" ");
int one = Integer.parseInt(resArray[0]);
int two = Integer.parseInt(resArray[2]);
int secret;
if (resArray[1].trim().equals("+"))
secret = one + two;
else if (resArray[1].trim().equals("-"))
secret = one - two;
else
secret = one * two;
System.out.println(one +" "+ resArray + " " + two + " = " + secret);
}
public static class TestString {
public void printSomething() {
System.out.println("3 + 6 = ");
}
}
}