mramine364

smart calc sqrt solution

Feb 27th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.26 KB | None | 0 0
  1. int fi = str.indexOf("(", 1);
  2. if( fi!=-1 ){
  3.     String function_name = str.substring(0,fi);
  4.     int epi = str.length()-1;
  5.     String parameter = str.substring(fi+1,epi);
  6.     if( function_name.equals("sqrt") ){
  7.         return Math.sqrt( calc(parameter) );
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment