Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. public class Class1
  2.     {
  3.         public decimal Calculate(decimal amount, int type, int years)
  4.         {
  5.             decimal result = 0;
  6.             decimal disc = (years > 5) ? (decimal) 5 / 100 : (decimal) years / 100;
  7.             if (type == 1)
  8.             {
  9.                 result = amount;
  10.             }
  11.             else if (type == 2)
  12.             {
  13.                 result = (amount - (0.1m * amount)) - disc * (amount - (0.1m * amount));
  14.             }
  15.             else if (type == 3)
  16.             {
  17.                 result = (0.7m * amount) - disc * (0.7m * amount);
  18.             }
  19.             else if (type == 4)
  20.             {
  21.                 result = (amount - (0.5m * amount)) - disc * (amount - (0.5m * amount));
  22.             }
  23.  
  24.             return result;
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement