For class I have an assignment that wants me to translate numerical values to the word equivalants. Up too 9999.
I achieved doing this with the dictionary command, but am unable to do so after setting up an Array. We're only our fourth week of class so its difficult for me.
Here are my arrays
string[] ToWordsOne = new string[10] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
string[] ToWordsTen = new string[8] { "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"};
string[] ToWordsTeens = new string[9] { "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
The program seems to recognize this just fine, but when I go to output the code it doesn't say anything or crashes (depending on the changes I make.)
int i = 0;
string output = "";
while (i <= input.Length)
{
if (i == (input.Length))
{
output = output + " " + ToWordsOne[i];
}
if (i == (input.Length))
{
if (input == 1)
{
output = ToWordsTeens[i];
}
else
{
output = output + ToWordsTen[i];
}
}
if (i == (input.Length))
{
output = output + ToWordsOne[i] + " hundred" + " ";
}
if (i == (input.Length))
{
output = ToWordsOne[i] + " thousand" + " ";
}
i++;
This is the code I used for outputting the results from dictionary. I am aware that I can't use the ".length" method. But I'm unaware of where to go from there.