I understand this is a question that has been asked before and I've gone through a lot of them but I really need some help.
I'm trying to create a console program for homework that takes user input of a number and then converts that number to its word counterpart. At the moment, I can create an array from the input and then generate an index. I can also return the char value as well as the index for that value. ie if input is 72 then it will return 7 = 0 and 2 = 1.
Now I basically have to create a class that will take that information and then run the code to return the words, trouble is though, I cannot make sense of classes at all. I've read all the notes, I've done extra reading and watched videos and I just cannot understand it at all. Asking my teacher gets me nowhere at all.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This program will convert numbers that you enter into their spoken English counterpart.\nExample: 100 = One Hundred.\n\nPlease enter your desired number to convert: ");
string getinput = (Console.ReadLine());
char[] getarray = getinput.ToCharArray();
for (int getindex = 0; getindex < getarray.Length; getindex++)
{
char getchar = getarray[getindex];
Console.WriteLine("getchar: " + getchar);
//Console.WriteLine("getarray: " + getarray);
Console.WriteLine("getindex: " + getindex);
//int convertinput = Convert.ToInt32(getinput);
}
}
class ToText
{
//attributes
private string[] ones = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; //each value is part of the array
private string[] teens = { "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; //array 0 in this set = "eleven" or tens[0] = "eleven"
private string[] tens = { "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety" };
private string[] moreThan99 = { "hundred", "thousand", "million", "billion", "trillion" };
//methods
public string ConvertToText()
{
}
//constructors
public ToText()
{
}
//destructors
~ToText()
{
}
}
}
I'm trying to understand what I need to do to push that information that I've created over to the class and then back again.
If anyone could help me understand what I'm doing, that would be much appreciated.
Thanks.