Advertisement
Guest User

fixedSolution

a guest
May 11th, 2015
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 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 TestExcercises
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] input;
  14.  
  15. string command;
  16.  
  17. long firstOperand;
  18.  
  19.  
  20. while (true)
  21. {
  22. input = Console.ReadLine().Split();
  23.  
  24. command = input[0];
  25. if (command == "END")
  26. {
  27. break;
  28. }
  29.  
  30. firstOperand = long.Parse(input[1]);
  31.  
  32. switch (command)
  33. {
  34. case "INC":
  35. {
  36. Console.WriteLine(IncrementNumber(firstOperand));
  37. break;
  38. }
  39. case "DEC":
  40. {
  41. Console.WriteLine(DecrementNumber(firstOperand));
  42. break;
  43. }
  44. case "ADD":
  45. {
  46. long secondOperand = long.Parse(input[2]);
  47. Console.WriteLine(AddNumbers(firstOperand, secondOperand));
  48. break;
  49. }
  50. case "MLA":
  51. {
  52. long secondOperand = long.Parse(input[2]);
  53. Console.WriteLine(MultiplycationNumbers(firstOperand, secondOperand));
  54. break;
  55. }
  56. case "END":
  57. {
  58. break;
  59. }
  60. }
  61. }
  62.  
  63. }
  64.  
  65. private static long IncrementNumber(long firstOperand)
  66. {
  67. long result = firstOperand + 1;
  68. return result;
  69. }
  70.  
  71. private static long DecrementNumber(long firstOperand)
  72. {
  73. long result = firstOperand - 1;
  74. return result;
  75. }
  76.  
  77. private static long MultiplycationNumbers(long firstOperand, long secondOperand)
  78. {
  79. long result = (long)firstOperand * (long)secondOperand;
  80. return result;
  81. }
  82.  
  83. private static long AddNumbers(long firstOperand, long secondOperand)
  84. {
  85. long result = firstOperand + secondOperand;
  86. return result;
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement