Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace JakeNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = "936";
- int inputInt = int.Parse(input);
- int[] inputDigits = new int[input.Length];
- for (int i = input.Length - 1; i >= 0; i--)
- {
- //Seprate the digits into an array
- inputDigits[i] = int.Parse(input.Substring(i, 1));
- }
- string[] numberNames = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen" };
- string[] tensNames = { "","teen", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety" };
- string output = "";
- if (inputInt == 0)
- {
- output = "zero";
- }
- else if (inputInt < 16)
- {
- output = numberNames[inputInt];
- }
- else if (inputInt < 20)
- {
- output = numberNames[inputDigits[1]] + tensNames[1];
- } else
- {
- int i = 0;
- if (input.Length == 3)
- {
- output = numberNames[inputDigits[i++]] + " hundred";
- if (inputDigits[i] + inputDigits[i + 1] != 0)
- {
- output += " and ";
- }
- }
- string dash = "-";
- if (inputDigits[i + 1] == 0 || inputDigits[i] == 0){
- dash = "";
- }
- output += tensNames[inputDigits[i++]] + dash + numberNames[inputDigits[i]];
- }
- Console.WriteLine(output);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement