import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.lang.*;
class godmos{

	public static StringBuffer deleter(StringBuffer s, int pos)
	{
		return new StringBuffer().append(s.substring(0, pos)).append(s.substring(pos + 1));

		}
	public String str1 = "5+7-9/9*2/4*3 ";
	StringBuffer str0 = new StringBuffer(str1);
	public static StringBuffer  calculate (StringBuffer str)

	 {
	//	StringBuffer str11;

	        while(str.indexOf("/")!=-1 | str.indexOf("*")!=-1 ){

		 if(str.indexOf("/") < str.indexOf("*") && str.indexOf("/")!=-1)
	   {   int a1 = str.indexOf("/");
		   int a2 = a1+1;
		   int a3 = a1-1;
		   String y1;
		   String y2;
           StringBuffer[] words = str.split("/",2);
           Pattern   p ,p1;
           Matcher   m ,m1;
           p = Pattern.compile("\\d*$");
           m = p.matcher(words[0]);
           p1 = Pattern.compile("^\\d*");
           m1 = p1.matcher(words[1]);
           while (m.find() && m1.find()){
           y1=m.group();
           y2=m1.group();}
		   double tmp1 = Double.parseDouble(y1);
		   double tmp2 = Double.parseDouble(y2);
		   double tmp3=tmp1/tmp2;
	       str.delete(a3,a2+1);
	       str.insert(a3,tmp3);
		 }
		 if(str.indexOf("*") < str.indexOf("/") && str.indexOf("*")!=-1)
	   {   int a4 = str.indexOf("*");
		   int a5 = a4+1;
		   int a6 = a4-1;
		   String y3;
		   String y4;
           String[] words = str.split("/",2);
           Pattern   p2,p11;
           Matcher   m2 ,m11;
           p2 = Pattern.compile("\\d*$");
           m2 = p2.matcher(words[0]);
           p11 = Pattern.compile("^\\d*");
           m11 = p11.matcher(words[1]);
           while (m2.find() && m11.find()){
           y3=m2.group();
           y4=m11.group();}
		   double tmp4 = Double.parseDouble(y3);
		   double tmp5 = Double.parseDouble(y4);

		   double tmp6=tmp4/tmp5;
	       str.delete(a6,a5+1);
	       str.insert(a6,tmp6);
		 }
		   System.out.print(str);

		 }

            while(str.indexOf("+")!=-1 | str.indexOf("-")!=-1 ){

		 if(str.indexOf("+") < str.indexOf("-") && str.indexOf("+")!=-1 )
	   {   int a11 = str.indexOf("+");
		   int a21 = a11+1;
		   int a31 = a11-1;
		   double tmp11 = Double.parseDouble(Character.toString(str.charAt(a31)));
		   double tmp21 = Double.parseDouble(Character.toString(str.charAt(a21)));
		   double tmp31=tmp11/tmp21;
	       str.delete(a31,a21+1);
	       str.insert(a31,tmp31);
		 }
		 if(str.indexOf("-") < str.indexOf("+") && str.indexOf("-")!=-1)
	   {   int a41 = str.indexOf("-");
		   int a51= a41+1;
		   int a61 = a41-1;
		   double tmp41 = Double.parseDouble(Character.toString(str.charAt(a61)));
		   double tmp51 = Double.parseDouble(Character.toString(str.charAt(a51)));
		   double tmp61=tmp41/tmp51;
	       str.delete(a61,a51+1);
	       str.insert(a61,tmp61);
		 }
		 }
		    return str;
	}

	StringBuffer f1 = calculate(str0);


	public static void main (String[] args) {
		godmos gm = new godmos();
        System.out.print(gm.f1);



	}
}
StringBuffer[] words = str.split("/",2); именно строка где есть слит видает такие ошибки