battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.


battle programming a forum for elite programmers with extreme will power to sharpen theire skills
 
HomeSearchRegisterLog in
 

 java float string trimmer

Go down 
AuthorMessage
kurosen
codding
codding
kurosen

Posts : 198
Join date : 2012-04-17

java float string trimmer Empty
PostSubject: java float string trimmer   java float string trimmer EmptyThu Mar 05, 2020 11:18 am

in out examples :
4.00000, 4
5.12000  5.12
9.6066, 9.6066

Code:
public static String floatTrimmer(String str1) {
      String tempStr = str1.substring(str1.length() - 1);
      if (!str1.contains(".")) {
         return str1;
      }
      if (tempStr.equals("0") || tempStr.equals(".")) {
         return floatTrimmer(str1.substring(0, str1.length() - 1));
      }
      return str1;
   }

code explains its self

cool
Back to top Go down
 
java float string trimmer
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
battle programmers alliance :: battle programming alliance :: battle programming-
Jump to: