//-----/Kapaz/Calculate.java----- package Kapaz; import eprog.*; public class Calculate { public static float CalcStr(String STRING) { int CLAMPS=0,OPERATOR=0,COUNTER=0; String NEWSUB; float SUM_1=0,SUM_2; for (int I=0;I klammmernausdruck { NEWSUB=STRING.substring(1,OPTPOS[I]-1); //extrahieren des ausdruckens, ohne klammern SUM_1=CalcStr(NEWSUB); // übergabe an Calculate.CalcStr } else // vor dem operator steht eine zahl { NEWSUB=STRING.substring(0,OPTPOS[I]); //zahl wird extrahiert SUM_1=Float.parseFloat(NEWSUB); //string in float umwandeln if (Math.round(Double.parseDouble(NEWSUB))>2147483647 || SUM_1==0) Error_m.Error_mm(); // zahl im bereich von int und positiv } } // ende if if (STRING.charAt(OPTPOS[I]+1)=='(') // klammer nach dem operator { if (I == OPTPOS.length-1) // letzter operator von der ebene NEWSUB=STRING.substring(OPTPOS[I]+2,STRING.length()-1); else NEWSUB=STRING.substring(OPTPOS[I]+2,OPTPOS[I+1]-1); SUM_2=CalcStr(NEWSUB); } else // nach dem operator eine zahl { if (I==OPTPOS.length-1) // letzter operator von der ebene NEWSUB=STRING.substring(OPTPOS[I]+1,STRING.length()); else NEWSUB=STRING.substring(OPTPOS[I]+1,OPTPOS[I+1]); SUM_2=Float.parseFloat(NEWSUB); //string in float umwandeln if (Math.round(Double.parseDouble(NEWSUB))>2147483647 || SUM_2==0) Error_m.Error_mm(); //zahl im bereich von int und positiv }//ende if if (STRING.charAt(OPTPOS[I])=='+') // serienschaltung SUM_1=1/((1/SUM_1)+(1/SUM_2)); else // parallelschaltung SUM_1+=SUM_2; } //ende for return (SUM_1); //endwert vom typ float } //ende CalcStr }