Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - More Exercise (02. English Name of the Last Digit)

Jun 18th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 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 EnglishNameOfTheLastDigit
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             string number = Console.ReadLine();
  15.  
  16.             if (number[number.Length - 1] == '0')
  17.             {
  18.                 Console.WriteLine("zero");
  19.             }
  20.             else if (number[number.Length - 1] == '1')
  21.             {
  22.                 Console.WriteLine("one");
  23.             }
  24.             else if (number[number.Length - 1] == '2')
  25.             {
  26.                 Console.WriteLine("two");
  27.             }
  28.             else if (number[number.Length - 1] == '3')
  29.             {
  30.                 Console.WriteLine("three");
  31.             }
  32.             else if (number[number.Length - 1] == '4')
  33.             {
  34.                 Console.WriteLine("four");
  35.             }
  36.             else if (number[number.Length - 1] == '5')
  37.             {
  38.                 Console.WriteLine("five");
  39.             }
  40.             else if (number[number.Length - 1] == '6')
  41.             {
  42.                 Console.WriteLine("six");
  43.             }
  44.             else if (number[number.Length - 1] == '7')
  45.             {
  46.                 Console.WriteLine("seven");
  47.             }
  48.             else if (number[number.Length - 1] == '8')
  49.             {
  50.                 Console.WriteLine("eight");
  51.             }
  52.             else if (number[number.Length - 1] == '9')
  53.             {
  54.                 Console.WriteLine("nine");
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement