Advertisement
KrasenPenev

between num

Jan 31st, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 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 Operation_between_num
  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. char operations = char.Parse(Console.ReadLine());
  16.  
  17. double result = 0;
  18.  
  19. if ((operations=='+'))
  20. {
  21. result = N1 + N2;
  22. if (result%2==0)
  23. {
  24. Console.WriteLine($"{N1} {operations} {N2} = {result} - even ");
  25. }
  26. else if (result%2==1)
  27. {
  28. Console.WriteLine($"{N1} {operations} {N2} = {result} - odd ");
  29. }
  30. }
  31. else if (operations=='-')
  32. {
  33. result = N1 - N2;
  34. if (result % 2 == 0)
  35. {
  36. Console.WriteLine($"{N1} {operations} {N2} = {result} - even ");
  37. }
  38. else if (result % 2 == 1)
  39. {
  40. Console.WriteLine($"{N1} {operations} {N2} = {result} - odd ");
  41. }
  42. }
  43. else if (operations=='*')
  44. {
  45. result = N1 * N2;
  46. if (result % 2==0)
  47. {
  48. Console.WriteLine($"{N1} {operations} {N2} = {result} - even ");
  49. }
  50. else if (result%2==1)
  51. {
  52. Console.WriteLine($"{N1} {operations} {N2} = {result} - odd ");
  53. }
  54. }
  55. else if (operations=='/')
  56. {
  57. result = N1 / N2;
  58. if (N1==0 || N2==0)
  59. {
  60. Console.WriteLine($"Cannot divide {N1} by zero");
  61. }
  62. Console.WriteLine($"{N1} {operations} {N2} = {result:F2} ");
  63. }
  64. else if (operations=='%')
  65. {
  66. result = (N1 * 1.0) % N2; // nz
  67. if (N1==0 || N2==0)
  68. {
  69. Console.WriteLine($"Cannot divide {N1} by zero");
  70. }
  71. Console.WriteLine($"{N1} % {N2} = {result}");
  72. }
  73.  
  74.  
  75.  
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement