
public class Number_function
{
//move from 5.50 to 5.5
public String CutTheZero(String num)
{
String[] num_array = num.split("\\.");
if(num_array.length >1)
{
double value = Double.parseDouble(num_array[1]);
num_array[1]= String.valueOf(value);
num = num_array[0]+ num_array[1];
}
return num;
}
//move from 5.5 to 5.50
public String AddTheZero(String num)
{
String[] num_array = num.split("\\.");
if(num_array.length >1)
{
num_array[1]= num_array[1] + "0";
num = num_array[0] + "." + num_array[1];
}
return num;
}
public String getaNumericString(int n)
{
// chose a Character random from this String
String AlphaNumericString = "123456789";
// create StringBuffer size of AlphaNumericString
StringBuilder sb = new StringBuilder(n);
for (int i = 0; i < n; i++)
{
// generate a random number between
// 0 to AlphaNumericString variable length
int index
= (int)(AlphaNumericString.length()
* Math.random());
// add Character one by one in end of sb
sb.append(AlphaNumericString
.charAt(index));
}
return sb.toString();
}
}