Calculator.cs 626 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. namespace Calculator
  3. {
  4. public class Calculator
  5. {
  6. public float Add(int a, int b) => a + b;
  7. public float Subtract(int a, int b) => a - b;
  8. public float Multiply(int a, int b) => a * b;
  9. public float Divide(int a, int b)
  10. {
  11. if (b == 0)
  12. throw new ArgumentException("Division by zero");
  13. return a / (float)b;
  14. }
  15. public float Power(int a, int b)
  16. {
  17. int c = 1;
  18. for (int i = 0; i < b; i++)
  19. {
  20. c *= a;
  21. }
  22. return c;
  23. }
  24. }
  25. }