import java.lang.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

 class xxx {
     private JFrame window;
    private JPanel mainPanel,inputPanel,   buttonPanel;
	 private JTextField jtxtNum1,jtxtNum2;
	 private JLabel  jlblNum1Caption,jlblNum2Caption;
	 private JButton jbtndey;


  // Scanner scanner = new Scanner(System.in);
   // String s = scanner.nextLine();
      private String[] tokens;/////////////////////////////////////////////////////////////////////////////////////////////////
      private int pos;/////////////////////////////////////////////////////////////////////////////////////////////////////////





/*

public xxx(){





	        window = new JFrame("Калькулятор");

        window = new JFrame("Калькулятор");


        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        window.setResizable(false);


        mainPanel = new JPanel(new BorderLayout());
        inputPanel = new JPanel();

	    buttonPanel = new JPanel();


        inputPanel.setLayout(new GridLayout(1, 4));

        buttonPanel.setLayout(new GridLayout(2, 4, 5, 5));


        mainPanel.add(inputPanel, BorderLayout.NORTH);
        mainPanel.add(buttonPanel, BorderLayout.CENTER);

	 addButtonsAndTextFields();

        window.getContentPane().add(mainPanel);




        window.pack();
        window.setLocationRelativeTo(null);
        window.setVisible(true);



}
*/


public  xxx(String expr)
{

    this.tokens = expr.split( "\\+|-");
    this.pos = 0;
	}
	public double calculate(){
	double first = multiply();
	while(pos < tokens.length)
	{
	   String operator = tokens[pos];

	       double second =multiply();
	       if(operator.equals("-")){
		   first += second;
	       }else{
		first -= second;


	       }


	    }
		return first;
		}


	public double multiply(){
	double first = Double.parseDouble(tokens[pos++]);
	while(pos < tokens.length)
	{
	   String operator = tokens[pos];
	   if (!operator.equals("*") && !operator.equals("/"))
	   {break;}
	   else
	   {
	       pos++;

	       }
	       double second = Double.parseDouble(tokens[pos++]);
	       if(operator.equals("*")){
		   first *= second;
	       }else{
		first /= second;


	       }


	    }
		return first;

		}






	public static void main(String[] args) {
	String expr = "5+5-5+5-5+5";
	xxx xx = new xxx(expr);
	System.out.println(xx.calculate());

		}



    }



	/*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	 ActionListener oty =  new ouyyss();
	 public void addButtonsAndTextFields() {


        jbtndey = new JButton("deystvio");





        jlblNum1Caption = new JLabel("Число 1:       ", JLabel.RIGHT);
         jlblNum2Caption = new JLabel("ответ:       ", JLabel.RIGHT);


        jtxtNum1 = new JTextField("");

	     jtxtNum2 = new JTextField("");
	       jbtndey.addActionListener(oty);

	        buttonPanel.add(jbtndey);

	inputPanel.add(jlblNum1Caption);
        inputPanel.add(jtxtNum1);
	inputPanel.add(jlblNum2Caption);
        inputPanel.add(jtxtNum2);

}


private class ouyyss implements ActionListener{

   @Override
    public void actionPerformed(ActionEvent event) {

        if (event.getSource() == jbtndey) {
            dey();
		}}

    }

		public void dey() {


}


	 }



class ze{
public static void main(String[] args) {



	xxx xx = new xxx();


		}

}