Advertisement
spasnikolov131

Untitled

Mar 22nd, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. using System;
  2. using static System.Console;
  3.  
  4. namespace The_begining
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. decimal N1 = decimal.Parse(Console.ReadLine());
  11. decimal N2 = decimal.Parse(Console.ReadLine());
  12. string symbol = Console.ReadLine();
  13.  
  14. decimal result = 0.00M;
  15. string output = string.Empty;
  16.  
  17. if (N2 == 0 && (symbol.Equals("/") || symbol.Equals("%")))
  18. {
  19. output = string.Format("Cannot divide {0} by zero", N1);
  20. }
  21. else if (symbol.Equals("/"))
  22. {
  23. result = N1 / N2;
  24. output = string.Format("{0} {1} {2} = {3:F2}", N1, symbol, N2, result);
  25.  
  26. }
  27. else if (symbol.Equals("%"))
  28. {
  29. result = N1 % N2;
  30. output = string.Format("{0} {1} {2} = {3}", N1, symbol, N2, result);
  31. }
  32. else
  33. if (symbol.Equals("+"))
  34. {
  35. result = N1 + N2;
  36. }
  37. else if (symbol.Equals("-"))
  38. {
  39. result = N1 - N2;
  40. }
  41. else if (symbol.Equals("*"))
  42. {
  43. result = N1 * N2;
  44. }
  45.  
  46. output = string.Format("{0} {1} {2} = {3} - {4}", N1, symbol, N2, result, result % 2 == 0
  47. ? "even" : "odd");
  48. Console.WriteLine(output);
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement