Hello! I need help on a program that I'm making. I already spent a lot of days for this but i just can't figure it out. The program that I'm trying to make is Converting words into numbers Ex. one to 1, one hundred to 100 etc...
the range of the numbers should be 1-1,000,000. I would be really happy if someone could help me.
Btw im just a beginner at this so i apologize if i don't understand it the first time. :|
Suppose you store your worded number in a string called strInput.
Your first step should be to see if you can extract each word from strInput (ie, words are seperated by spaces). There are various techniques of accomplishing this, ie find position of first space in input, then extract [substring] from start to that position, then remove extracted portion from strInput ...
Once you have extracted the words from the original string, you can compare each word to a group of predefined arrays of values: like {"zero", "one", "two" ..., "nine"} and {"ten", "eleven", "twelve", ... "nineteen"} and {"twenty", "thirty", "forty", ..., "ninety"} and {"hundred", "thousand", "million"}.
If you have a match, then we apply the corresponding logical weight to our final number. So ... if we have strInput = [twenty five], the corresponding weight will be: