LexarG56

Generation

generate functionSun, 18 Jun 2023

como agrego que un int sea para palabras

String numberToWords(int num) { if (num == 0) return "Zero"; int billion = num / 1000000000; int million = (num - billion * 1000000000) / 1000000; int thousand = (num - billion * 1000000000 - million * 1000000) / 1000; int rest = num - billion * 1000000000 - million * 1000000 - thousand * 1000; String result = ""; if (billion != 0) result = threeDigit(billion) + " Billion"; if (million != 0) { if (!result.isEmpty()) result += " "; result += threeDigit(million) + " Million"; } if (thousand != 0) { if (!result.isEmpty()) result += " "; result += threeDigit(thousand) + " Thousand"; } if (rest != 0) { if (!result.isEmpty()) result += " "; result += threeDigit(rest); } return result

Questions about programming?Chat with your personal AI assistant