Advertisement
meta1211

Untitled

Feb 23rd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3. using namespace System;
  4.  
  5. double a;
  6. double b;
  7. double result;
  8.  
  9. enum operators
  10. {
  11. plus = 1,
  12. minus = 2,
  13. multiply = 3,
  14. division = 4
  15. };
  16.  
  17. String^ inputNum(char n, String^ currentNum)
  18. {
  19. return currentNum = currentNum + n;
  20. }
  21. String^ conversion(String^ firstNum, String^ secondNum, int operation)
  22. {
  23. a = Convert::ToDouble(firstNum);
  24. b = Convert::ToDouble(secondNum);
  25. switch (operation)
  26. {
  27. case plus:
  28. {
  29. result = a + b;
  30. break;
  31. }
  32. case minus:
  33. {
  34. result = a - b;
  35. break;
  36. }
  37. case multiply:
  38. {
  39. result = a * b;
  40. break;
  41. }
  42. case division:
  43. {
  44. result = a / b;
  45. break;
  46. }
  47. default:
  48. {
  49. Exception("Operation not found!");
  50. break;
  51. }
  52. }
  53. return Convert::ToString(result);
  54. }
  55. int getOperator(String^ curOper)
  56. {
  57. if (curOper == "+")
  58. return 1;
  59. if (curOper == "-")
  60. return 2;
  61. if (curOper == "*")
  62. return 3;
  63. if (curOper == "/")
  64. return 4;
  65. return -1;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement