java - Converting an input word number (like seven) into a character (like @) -


Thus if the user types down seven with the scanner, then @@@@@@ (7) will output . I have to use for a Loop statement but I can at least understand that figure Need help in finding a way to convert word numbers into numerical numbers and finally convert them to a random character. The first thing you need to do is a valid number string in the number "ten", " Twenty-five "etc., then passes that number into the loop.

So, you need to write a token parser to basically convert the word to a number. By defining the tokens, you can easily convert an int. (I'm only dealing with the insights in this example).

Clear token:

  1. One, two, three, etc. (1 to nineteen). (Call this number).
  2. Twenty, thirty, forty, etc. (twenty to ninety). (Call this tens)
  3. hundred, thousand, etc. (call this power)

"", "and" and "-" the form of delimiter (Normal method in one hundred and six or twenty-five)

Then you can parse your string in tokens, and with this you should convert your rules to an int. Start from the right and do the left, you follow some rules. Linking to work continuously with two tokens at a time will be a special case of powers, where you will multiply by the previous digits

For example, "one hundred twenty seven" will be converted to a token:

Digit Power Tens Digit

(7 + 20) + (1 * 100) =

(Digit + TNS) + (Digit * Power) )

After that conversion, you can easily convert it to a repeated string for your loop.

I hope that you will start on the right direction.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -