package com.javarush.task.task19.task1914;

/*
Решаем пример
*/

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Solution {
    public static TestString testString = new TestString();

    public static void main(String[] args) {
        PrintStream printStream = System.out;
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        PrintStream stream = new PrintStream(outputStream);
        System.setOut(stream);
        testString.printSomething();
        String s = outputStream.toString();
        Matcher m = Pattern.compile("(\\d+) ([\\+\\-\\*]) (\\d+)").matcher(s);
        int i=0;
        String st = null;
        if (m.find()) {
            if ((st="+").equals(m.group(2))){
                i = Integer.parseInt(m.group(1))+Integer.parseInt(m.group(3));
            }
     else if ((st="-").equals(m.group(2))){
                i = Integer.parseInt(m.group(1))-Integer.parseInt(m.group(3));
            }
     else{
         i = Integer.parseInt(m.group(1))*Integer.parseInt(m.group(3));
         st = "*";
            }
            System.setOut(printStream);
            System.out.print(m.group(1)+" "+st+" "+m.group(3)+" "+"="+" "+i);
        }
    }

    public static class TestString {
        public void printSomething() {
            System.out.println("3 + 6 = ");
        }
    }
}