public class Main {
public Main(){
float res = calc(formula);
System.
out.
println("Result is equal to: " + res
);
}
String formula
= "7 - 5 + 3 - 2 - 3";
formula = formula.replaceAll("\\s+", "");
Func root = null;
for(int i = formula.length() - 1; i > 0; i--){
if(formula.charAt(i) == '+'){
System.
out.
println("Create root addition: " + formula
);
String a
= formula.
substring(0, i
);
String b
= formula.
substring(i
+ 1, formula.
length());
System.
out.
println(a
+ ":" + b
);
root = new Func(Func.OP_TYPE.ADDITION, a, b);
break;
} else if(formula.charAt(i) == '-'){
System.
out.
println("Create root subtraction: " + formula
);
String a
= formula.
substring(0, i
);
String b
= formula.
substring(i
+ 1, formula.
length());
root = new Func(Func.OP_TYPE.SUBTRACTION, a, b);
break;
}
}
root.printONP();
return root.calc();
}
public static void main
(String[] args
){
System.
out.
println("PROGRAM START");
new Main();
System.
out.
println("PROGRAM END");
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}