Advertisement
YavorJS

20. English Name Of The Last Digit

Jul 23rd, 2016
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8.  
  9. int n = int.Parse(Console.ReadLine());
  10. string name = englishName(n);
  11. Console.WriteLine(name);
  12. }
  13.  
  14. private static string englishName(int num)
  15. {
  16. string lastDigit = "";
  17. int lastNumber = num % 10;
  18. switch (lastNumber)
  19. {
  20. case 0:
  21. lastDigit = "zero";
  22. break;
  23. case 1:
  24. lastDigit = "one";
  25. break;
  26. case 2:
  27. lastDigit = "two";
  28. break;
  29. case 3:
  30. lastDigit = "three";
  31. break;
  32. case 4:
  33. lastDigit = "four";
  34. break;
  35. case 5:
  36. lastDigit = "five";
  37. break;
  38. case 6:
  39. lastDigit = "six";
  40. break;
  41. case 7:
  42. lastDigit = "seven";
  43. break;
  44. case 8:
  45. lastDigit = "eight";
  46. break;
  47. case 9:
  48. lastDigit = "nine";
  49. break;
  50. default:
  51. break;
  52. }//end of switch
  53. return lastDigit;
  54. }//end of englishName
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement