static void Main(string[] args) { Start: // string isaac = Console.ReadLine(); // Console.WriteLine(isaac.Length); //number to convert to text SpeechSynthesizer synth = new SpeechSynthesizer(); synth.Speak("Enter an input"); //do //{ //} while (b); Console.WriteLine("PLEASE ENTER A NUMBER THAT THE COMPUTER WILL CONVERT TO A STRING AUTOMATICALLY"); Console.WriteLine("The maximum number you can enter is 1 billion"); string input = Console.ReadLine(); //string input = ("78"); //test to check the length of the input if (input.Length == 1) { string result = Units.Unit(input[0]); Console.WriteLine("You entered {0}", result); synth.Speak(result); } else if (input.Length == 2) { string result = Tens.Ten(input); Console.WriteLine("You entered {0}", result); synth.Speak(result); } else if (input.Length == 3) { string result = Hundreds.Hundred(input); Console.WriteLine("You entered {0}", result); synth.Speak(result); } else if (input.Length >= 4 && input.Length <= 6) { string result = Thousands.Thousand(input); Console.WriteLine("You entered {0}", result); //synth.Speak(result); } else if (input.Length >= 7 && input.Length <= 9) { string result = Million.Millions(input); Console.WriteLine("You entered {0}", result); //synth.Speak(result); } else if (input == "10000000000") { Console.WriteLine("You entered 1 billion "); } else { Console.WriteLine("the number is above the expected range, The max number is 1billion"); } goto Start; //else if (input.Length == 5) //{ // string result = TenThousand.TenThousands(input); // Console.WriteLine("You entered {0}", result); // //synth.Speak(result); //} }
public static string Millions(string million) { string millionWord = "Million"; string and; string millionResult = String.Empty; string thousandResult = String.Empty; /* the thousand part of the million, * this will call the thousand method in the Thousand class */ string thousandPart = String.Empty; /* the "million" / first part, * this part will call the hundred method in the Hundred class*/ string millionPart = String.Empty; // Thousands.Thousand(thousandPart); if (million.Length == 7) { millionPart = million.Substring(0, 1); /*since the first part is just 0ne it adds 2 zeros to it at the beginning, since you can only call the * the hundred method with a number with a lenght of 3, adding zero before it is negliable and does't change its value*/ millionPart = "00" + millionPart; thousandPart = million.Substring(1); } else if (million.Length == 8) { millionPart = million.Substring(0, 2); millionPart = "0" + millionPart; thousandPart = million.Substring(2); } else { millionPart = million.Substring(0, 3); thousandPart = million.Substring(3); } // second part is not zero if (thousandPart != "000000") { thousandResult = Thousands.Thousand(thousandPart); and = "and"; } else { if (millionPart == "000") { thousandResult = Thousands.Thousand(thousandPart); } and = string.Empty; } //if (thousand[0] != '0') if (millionPart != "000") { millionResult = Hundreds.Hundred(millionPart); //millionResult = Units.Unit(firstnumber); } else { millionResult = String.Empty; and = String.Empty; millionWord = string.Empty; } return(millionResult + " " + millionWord + " " + and + " " + thousandResult); }