Currently I'm attempting to convert a number to a word, but I'm unable to get the result that I want. Basically, my question is if I can convert a double to a string, the number converted into words, one for each decimal number, including the decimal points.
This is my method
String numberInWords (double numbers){
String result = "" + numbers;
for (int i = 0; i < result.length(); i++) {
if( i == 0) {
result += "zero";
}
if(i == 1) {
result += "one";
}
if(i == 2) {
result += "two";
}
if(i == 3) {
result += "three";
}
if(i == 4) {
result += "four";
}
if(i == 5) {
result += "five";
}
if(i == 6) {
result += "six";
}
if(i == 7) {
result += "seven";
}
if(i == 8) {
result += "eight";
}
if(i == 9) {
result += "nine";
}
}
return result;
}
and the result :
Expected :two three
Actual :23.0zeroonetwothreefourfivesixseveneightnine