Advertisement
Guest User

program

a guest
Mar 29th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. class Program
  2. {
  3. static void verify(string input, int res)
  4. {
  5. Calculate line = new Calculate(input);
  6. int got = line.calculateIt();
  7. if (got != res) Console.Write("For " + input + " Value = " + got + " Expexted : " + res + "\n");
  8. }
  9. static void verify(string input, string res)
  10. {
  11. CalculateX line = new CalculateX(input);
  12. string got = line.calculateIt();
  13. if (Convert.ToBoolean(string.Compare(got,res)) ) Console.Write("For " + input + " Value = " + got + " Expexted : " + res + "\n");
  14. }
  15. static void runTests()
  16. {
  17. verify("15+5*11", 70);
  18. verify("-24-16+77", 37);
  19. verify("12*3*7-15*8", 132);
  20. verify("-15*9+65", -70);
  21. verify("3-2*-5*3*-2+7", -50);
  22. verify("5*12*-5*-3", 900);
  23. verify("7+9*-4+23", -6);
  24. verify("12+(22+5*-3-15)", 4);
  25. verify("((5-2)*3)-9", 0);
  26. verify("-(10-15)*5+23", 48);
  27. verify("(5-1)*(2-4)", -8);
  28. verify("12+(-12+7)*5", -13);
  29. verify("[([5-2]*[3])-9]", 0);
  30. verify("2*x-6+x 4 7", "6 9 12 15 ");
  31. verify("2*q-6+q 4 7", "6 9 12 15 ");
  32. verify("4^2*3", 48);
  33. verify("4*-3^2", -36);
  34. verify("(5-1)^(4-2)", 16);
  35. verify("(-1)^(4-2)", 1);
  36. verify("(-2)^(3)", -8);
  37. }
  38. static void Main(string[] args)
  39. {
  40. runTests();
  41. string input = Console.ReadLine();
  42.  
  43. CalculateX line = new CalculateX(input);
  44. string res = line.calculateIt ();
  45. Console.Write(res);
  46.  
  47. Console.ReadKey();
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement