Guest User

Untitled

a guest
Oct 30th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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 ConsoleApp23
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double n1 = double.Parse(Console.ReadLine());
  14. double n2 = double.Parse(Console.ReadLine());
  15. string symbol = Console.ReadLine();
  16. double result = 0;
  17.  
  18. if (symbol == "+")
  19. {
  20. result = (n1 + n2);
  21. if (result % 2 == 0)
  22. {
  23. Console.WriteLine("{0} {1} {2} = {3} - even", n1, symbol, n2, result);
  24. }
  25. else if (result % 2 == 1)
  26. {
  27. Console.WriteLine("{0} {1} {2} = {3} - odd", n1, symbol, n2, result);
  28. }
  29. }
  30. else if (symbol == "-")
  31. {
  32. result = (n1 - n2);
  33. if (result % 2 == 0)
  34. {
  35. Console.WriteLine("{0} {1} {2} = {3} - even", n1, symbol, n2, result);
  36. }
  37. else if (result % 2 == 1)
  38. {
  39. Console.WriteLine("{0} {1} {2} = {3} - odd", n1, symbol, n2, result);
  40. }
  41. }
  42. else if (symbol == "*")
  43. {
  44. result = (n1 * n2);
  45. if (result % 2 == 0)
  46. {
  47. Console.WriteLine("{0} {1} {2} = {3} - even", n1, symbol, n2, result);
  48. }
  49. else if (result % 2 == 1)
  50. {
  51. Console.WriteLine("{0} {1} {2} = {3} - odd", n1, symbol, n2, result);
  52. }
  53. }
  54. else if (symbol == "/")
  55. {
  56. result = n1 / n2;
  57. if (n2 != 0)
  58. {
  59. Console.WriteLine("{0} {1} {2} = {3}", n1, symbol, n2, result);
  60. }
  61. else
  62. {
  63. Console.WriteLine("Cannot divide {0} by zero", n1);
  64. }
  65. }
  66. else if (symbol == "%")
  67. {
  68. result = n1 % n2;
  69. if (n2 != 0)
  70. {
  71. Console.WriteLine("{0} {1} {2} = {3}", n1, symbol, n2, result);
  72. }
  73. else
  74. {
  75. Console.WriteLine("Cannot divide {0} by zero", n1);
  76. }
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment