Results 1 to 14 of 14
- 11-15-2011, 09:56 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 31
- Rep Power
- 0
- 11-15-2011, 03:21 PM #2
Re: how to change numbers into word numbers?
For the first one? Look at the NumberFormat class.
For the second one? How do you do that in your head?How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 11-15-2011, 04:51 PM #3
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Re: how to change numbers into word numbers?
Here's something to start you off:
Modify that to deal with tens, hundreds, thousands and so forth.Java Code:final String[] nums0To19 = {"zero", "one", "two", /* ... */ "nineteen"}; public void speakNum(int num) { System.out.println(nums0To19[num]); }
- 11-15-2011, 05:32 PM #4
Re: how to change numbers into word numbers?
Also look at division to get the number of 1000's for example.
- 11-16-2011, 09:39 AM #5
Member
- Join Date
- Oct 2011
- Posts
- 31
- Rep Power
- 0
Re: how to change numbers into word numbers?
okay thanks for the suggestions so far. Will try it out right now
- 11-16-2011, 10:47 PM #6
Member
- Join Date
- Oct 2011
- Posts
- 31
- Rep Power
- 0
Re: how to change numbers into word numbers?
okay i'm still stuck. Right now, i have the digits in a character array box.
eg. if the input was 123,
it would be held in a char [] number = (1,2,3) box.
i can't figure how how to put seperators with the number format class, and i can't figure how how to tell the size of each digit. (I got it to print one two three for the input 123).
- 11-16-2011, 11:04 PM #7
Re: how to change numbers into word numbers?
In what format are you getting the input? As a String: "123" or as an int: 123 or as three chars: '1', '2', '3'?
What statement(s) are you using to get the input?
- 11-16-2011, 11:13 PM #8
Member
- Join Date
- Nov 2011
- Posts
- 65
- Rep Power
- 0
Re: how to change numbers into word numbers?
Many replys here though i've noticed noone gave you a definative answer to exactly what your looking for;
best described I think I would say you are trying to convert a integer into a numeric string and also asking how to format an integer to a string in words
I'll try to look into what your trying to do and see if I can find anything, personnaly i've never found a need to convert a number into the word equivalent-- best of luck
- 11-16-2011, 11:14 PM #9
- 11-16-2011, 11:16 PM #10
Re: how to change numbers into word numbers?
- 11-17-2011, 07:17 AM #11
Member
- Join Date
- Oct 2011
- Posts
- 31
- Rep Power
- 0
Re: how to change numbers into word numbers?
it was a string input, but i returned it into a character. It cannot be in an int type because it the number can be greater than int's capacity.
- 11-17-2011, 07:32 AM #12
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
Re: how to change numbers into word numbers?
Hi,
Please check the below code.
import java.text.DecimalFormat;
public class ConvertIntToString {
public static void main(String[] args) {
String aString = "1003";
int aInt= Integer.parseInt(aString);
System.out.println(aInt);
DecimalFormat df = new DecimalFormat("#,##0;(#,##0)");
System.out.println(df.format(aInt));
}
}
Thanks
Lakshmi M
- 11-17-2011, 07:36 AM #13
Member
- Join Date
- Nov 2011
- Posts
- 2
- Rep Power
- 0
Re: how to change numbers into word numbers?
Hi,
Below is the program to convert an integer into words.
[ spoonfeeding deleted - Jos ]
Regards
Lakshmi MLast edited by JosAH; 11-17-2011 at 09:45 AM. Reason: spoonfeeding ...
- 11-18-2011, 08:46 AM #14
Member
- Join Date
- Oct 2011
- Posts
- 31
- Rep Power
- 0
Similar Threads
-
how to count numbers under 5.5
By pinotje in forum New To JavaReplies: 10Last Post: 05-10-2011, 05:53 PM -
Problem getting numbers from user and finding smallest two numbers
By radhi16 in forum New To JavaReplies: 11Last Post: 01-14-2011, 06:36 PM -
Sum of 4 numbers...!?
By xmenus in forum New To JavaReplies: 7Last Post: 02-14-2010, 03:36 PM -
printing two smallest numbers from a series of numbers
By trofyscarz in forum New To JavaReplies: 2Last Post: 10-14-2008, 11:46 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks