# Thread: Convert Integer into String

1. Member
Join Date
Nov 2015
Posts
2
Rep Power
0

## Convert Integer into String

Hi All,

I am new to JAVA. I am working on one assignment given by my mentor.

Requirement:

1) Convert Integer to String.

Ex1: 234: Two Hundred Thirty Four

Ex2: 1456: One Thousand Four Hundred Fifty Six

Could you please help me.

Regards.

2. ## Re: Convert Integer into String

What have you tried? Did your mentor give you any clues? Do you have to work with the int value or can you convert it to a String?

3. Member
Join Date
Nov 2015
Posts
2
Rep Power
0

## Re: Convert Integer into String

Hi,

I wrote the logic to convert the numbers into Strings.

Ex: If User gives 5 as input, Output should be FIVE.

I wrote very cumbersome logic as mentioned below.

1) First Find out the length of the Value

2) If the length is 1, it is either ONE or TWO and so on till NINE

3) If the length is 2, hard coded values from ELEVEN to NINETEEN

4) Now I am writing logic to write the text for values greater than 21.

Regards.

4. ## Re: Convert Integer into String

Sounds like you are making progress. Some of the code will have to be hand tailored for the numbers like 10 to 19.
Above 19 you should be able to use an array that holds the names like Twenty, Thirty etc and then use the digits value to index into the array.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•