Advertisement
simonradev

Test

May 14th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. namespace _1000DaysAfterBirth
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Globalization;
  6.     using System.Linq;
  7.     using System.Text;
  8.     using System.Threading.Tasks;
  9.    
  10.     public class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.             int numberInput = int.Parse(Console.ReadLine());
  15.  
  16.             string[] firstNineteenNumbers = new string[]
  17.             {
  18.                 "Zero",
  19.                 "One",
  20.                 "Two",
  21.                 "Three",
  22.                 "Four",
  23.                 "Five",
  24.                 "Six",
  25.                 "Seven",
  26.                 "Eight",
  27.                 "Nine",
  28.                 "Ten",
  29.                 "Eleven",
  30.                 "Twelve",
  31.                 "Thirteen",
  32.                 "Fourteen",
  33.                 "Fifteen",
  34.                 "Sixteen",
  35.                 "Seventeen",
  36.                 "Eighteen",
  37.                 "Nineteen"
  38.             };
  39.  
  40.             string result = string.Empty;
  41.             if (numberInput >= 0 && numberInput <= 19)
  42.             {
  43.                 result = firstNineteenNumbers[numberInput];
  44.             }
  45.             else if (numberInput >= 20 && numberInput < 100)
  46.             {
  47.                 string[] tens = new string[] { "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety " };
  48.  
  49.                 string secondNumber = numberInput % 10 == 0 ? string.Empty : firstNineteenNumbers[numberInput % 10];
  50.  
  51.                 result = (tens[numberInput / 10 - 2] + secondNumber);
  52.             }
  53.             else if (numberInput == 100)
  54.             {
  55.                 result = "one hundred";
  56.             }
  57.  
  58.             Console.WriteLine(result.TrimEnd());
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement