public class ReturnDecimalValueGivenString {
public static void main(String[] args) {
String ss = "";
isDigitValue(ss);
}
public static String isDigitValue(String s4) {
String s1 = s4;
System.out.println("Givne Value:"+s4);
if(s1.length() == 0){
System.out.println("Given value is empty.");
return "";
} else if (s1.contains(".")) {
String[] s5 = s1.split("\\.");
for (String s6 : s5) {
s1 = s6;
System.out.println("Givne value with out decimal:"
+s6);
break;
}
}else{
System.out.println("No decimal value from given string."
);
}
return s1;
}
}
//Output:
//Scenario 1:
//Given Value:144333.9566666
//Given value with out decimal:144333
//Scenario 2:
//Given Value:144333.11
//Given value with out decimal:144333
//Scenario 3:
//Given Value:112
//No decimal value from given string.
//Scenario 4:
//Givne Value:
//Given value is empty.
Build Your Own Test Framework
-
[image: Build Your Own Test Framework]
Learn to write better automated tests that will dramatically increase your
productivity and have fun while doing so...
1 hour ago
No comments:
Post a Comment
I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.