Advertisement
Guest User

Number 0...100 to Text

a guest
Oct 22nd, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int a = int.Parse(Console.ReadLine());
  14.             int a1 = 0;
  15.             int a2 = 0;
  16.  
  17.             if(a>=0 && a<=19)
  18.             {
  19.                 if(a==0)
  20.                     Console.WriteLine("zero");
  21.  
  22.                 else if(a==1)
  23.                     Console.WriteLine("one");
  24.  
  25.                 else if (a == 2)
  26.                     Console.WriteLine("two");
  27.  
  28.                 else if (a == 3)
  29.                     Console.WriteLine("three");
  30.  
  31.                 else if (a == 4)
  32.                     Console.WriteLine("four");
  33.  
  34.                 else if (a == 5)
  35.                     Console.WriteLine("five");
  36.  
  37.                 else if (a == 6)
  38.                     Console.WriteLine("six");
  39.  
  40.                 else if (a == 7)
  41.                     Console.WriteLine("seven");
  42.  
  43.                 else if (a == 8)
  44.                     Console.WriteLine("eight");
  45.  
  46.                 else if (a == 9)
  47.                     Console.WriteLine("nine");
  48.  
  49.                 else if (a == 10)
  50.                     Console.WriteLine("ten");
  51.  
  52.                 else if (a == 11)
  53.                     Console.WriteLine("eleven");
  54.  
  55.                 else if (a == 12)
  56.                     Console.WriteLine("twelve");
  57.  
  58.                 else if (a == 13)
  59.                     Console.WriteLine("thirteen");
  60.  
  61.                 else if (a == 14)
  62.                     Console.WriteLine("fourteen");
  63.  
  64.                 else if (a == 15)
  65.                     Console.WriteLine("fifteen");
  66.  
  67.                 else if (a == 16)
  68.                     Console.WriteLine("sixteen");
  69.  
  70.                 else if (a == 17)
  71.                     Console.WriteLine("seventeen");
  72.  
  73.                 else if (a == 18)
  74.                     Console.WriteLine("eighteen");
  75.  
  76.                 else if (a == 19)
  77.                     Console.WriteLine("nineteen");
  78.             }
  79.  
  80.             else if (a>=10 && a<=99)
  81.             {
  82.                 a1 = a / 10;
  83.                 a2 = a % 10;
  84.  
  85.                 if(a1==2)
  86.                     Console.Write("twenty");
  87.  
  88.                 else if (a1 == 3)
  89.                     Console.Write("thirty");
  90.  
  91.                 else if (a1 == 4)
  92.                     Console.Write("forty");
  93.  
  94.                 else if (a1 == 5)
  95.                     Console.Write("fifty");
  96.  
  97.                 else if (a1 == 6)
  98.                     Console.Write("sixty");
  99.  
  100.                 else if (a1 == 7)
  101.                     Console.Write("seventy");
  102.  
  103.                 else if (a1 == 8)
  104.                     Console.Write("eighty");
  105.  
  106.                 else if (a1 == 9)
  107.                     Console.Write("ninety");
  108.  
  109.                 if (a2 == 1)
  110.                     Console.WriteLine(" one");
  111.  
  112.                 else if (a2 == 2)
  113.                     Console.WriteLine(" two");
  114.  
  115.                 else if (a2 == 3)
  116.                     Console.WriteLine(" three");
  117.  
  118.                 else if (a2 == 4)
  119.                     Console.WriteLine(" four");
  120.  
  121.                 else if (a2 == 5)
  122.                     Console.WriteLine(" five");
  123.  
  124.                 else if (a2 == 6)
  125.                     Console.WriteLine(" six");
  126.  
  127.                 else if (a2 == 7)
  128.                     Console.WriteLine(" seven");
  129.  
  130.                 else if (a2 == 8)
  131.                     Console.WriteLine(" eight");
  132.  
  133.                 else if (a2 == 9)
  134.                     Console.WriteLine(" nine");
  135.             }
  136.  
  137.             else if(a==100)
  138.                 Console.WriteLine("one hundred");
  139.  
  140.             else
  141.                 Console.WriteLine("invalid number");
  142.         }
  143.     }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement