Advertisement
BojidarDosev

Meтод , switch , odd/even

Feb 14th, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp7
  4. {
  5. class Program
  6. {
  7. static string OddEven(int a)
  8. {
  9. string s = "";
  10. switch (a)
  11. {
  12. case 0: case 2: case 4: case 6: case 8:
  13. s = "even";
  14. break;
  15. case 1: case 3: case 5: case 7: case 9:
  16. s = "odd";
  17. break;
  18. }
  19. return s;
  20. }
  21.  
  22. static string Last(int a)
  23. {
  24. string s = "";
  25. switch (a)
  26. {
  27. case 0:
  28. s = "zero";
  29. break;
  30. case 1:
  31. s = "one";
  32. break;
  33. case 2:
  34. s = "two";
  35. break;
  36. case 3:
  37. s = "three";
  38. break;
  39. case 4:
  40. s = "four";
  41. break;
  42. case 5:
  43. s = "five";
  44. break;
  45. case 6:
  46. s = "six";
  47. break;
  48. case 7:
  49. s = "seven";
  50. break;
  51. case 8:
  52. s = "eight";
  53. break;
  54. case 9:
  55. s = "nine";
  56. break;
  57. }
  58. return s;
  59. }
  60. static void Main(string[] args)
  61. {
  62. int a = int.Parse(Console.ReadLine());
  63. a = a % 10;
  64. Console.WriteLine(Last(a));
  65. Console.WriteLine(OddEven(a));
  66. }
  67. }
  68. }
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement