Advertisement
Guest User

Untitled

a guest
Sep 1st, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 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 _03.Operations
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var n1 = int.Parse(Console.ReadLine());
  14. var n2 = int.Parse(Console.ReadLine());
  15. char o = char.Parse(Console.ReadLine());
  16. double result = 0;
  17. if (n2 == 0 && (o == '/' || o == '%'))
  18. {
  19. Console.WriteLine("Cannot divide {0} by zero",n1);
  20. return;
  21. }
  22. if (o == '/')
  23. {
  24. result = Math.Round(n1 * 1.00 / n2,2);
  25. Console.WriteLine("{0} / {1} = {2:f2}",n1 , n2 ,result);
  26. }
  27. else if (o == '%')
  28. {
  29. var reminder = n1 % n2;
  30. Console.WriteLine("{0} % {1} = {2}",n1 ,n2 ,reminder);
  31. }
  32. else
  33. {
  34. if (o == '+')
  35. {
  36. result = n1 + n2;
  37. if (result % 2 == 0)
  38. {
  39. Console.WriteLine("{0} + {1} = {2} - even",n1 , n2 ,result);
  40. }
  41. else Console.WriteLine("{0} + {1} = {2} - odd", n1, n2, result);
  42. }
  43. else if (o == '-')
  44. {
  45. result = n1 - n2;
  46. if (result % 2 == 0)
  47. {
  48. Console.WriteLine("{0} - {1} = {2} - even", n1, n2, result);
  49. }
  50. else Console.WriteLine("{0} - {1} = {2} - odd", n1, n2, result);
  51. }
  52. else if (o == '*')
  53. {
  54. result = n1 * n2;
  55. if (result % 2 == 0)
  56. {
  57. Console.WriteLine("{0} * {1} = {2} - even", n1, n2, result);
  58. }
  59. else Console.WriteLine("{0} * {1} = {2} - odd", n1, n2, result);
  60. }
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement