Calculator.cs 816 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Calculation
  7. {
  8. public class Calculator
  9. {
  10. public int Calc(decimal price, int count)
  11. {
  12. int sale = 0;
  13. if (count > 0 && price > 0)
  14. {
  15. if (count >= 3)
  16. {
  17. sale = 5;
  18. }
  19. if (count >= 5)
  20. {
  21. sale = 10;
  22. }
  23. if (count >= 10)
  24. {
  25. sale = 15;
  26. }
  27. if (price / 500 >= 1)
  28. {
  29. sale += Convert.ToInt32(Math.Floor(price / 500));
  30. }
  31. }
  32. return sale;
  33. }
  34. }
  35. }