Advertisement
VelizarAvramov

03. English Name of Last Digit

Nov 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03._English_Name_of_Last_Digit
  4. {
  5.     class EnglishNameOfTheLastDigit
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             long number = Math.Abs(long.Parse(Console.ReadLine()));
  10.             string lastDigit = GetName(Math.Abs(number));
  11.             Console.WriteLine(lastDigit);
  12.  
  13.         }
  14.  
  15.         private static string GetName(long number)
  16.         {
  17.             string lastDigit = "";
  18.             long current = number % 10;
  19.  
  20.             switch (current)
  21.             {
  22.                 case 0:
  23.                     lastDigit = "zero";
  24.                     break;
  25.                 case 1:
  26.                     lastDigit = "one";
  27.                     break;
  28.                 case 2:
  29.                     lastDigit = "two";
  30.                     break;
  31.                 case 3:
  32.                     lastDigit = "tree";
  33.                     break;
  34.                 case 4:
  35.                     lastDigit = "four";
  36.                     break;
  37.                 case 5:
  38.                     lastDigit = "five";
  39.                     break;
  40.                 case 6:
  41.                     lastDigit = "six";
  42.                     break;
  43.                 case 7:
  44.                     lastDigit = "seven";
  45.                     break;
  46.                 case 8:
  47.                     lastDigit = "eigth";
  48.                     break;
  49.                 case 9:
  50.                     lastDigit = "nine";
  51.                     break;
  52.                 default:
  53.                     break;
  54.             }
  55.             return lastDigit;
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement