Пример #1
0
        static void Main()
        {
            Console.WriteLine("Input format{money}{interest}{years}{type}");

            while (true)
            {
                string[] commandargs = Console.ReadLine().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                if (commandargs[0].Equals("end"))
                {
                    break;
                }

                decimal money = decimal.Parse(commandargs[0]);
                double interest = double.Parse(commandargs[1]);
                int years = int.Parse(commandargs[2]);

                InterestCalculator calculator = null;

                switch (commandargs[3])
                {
                    case "compound":
                        calculator = new InterestCalculator(money, interest, years, new CalculateInterestDelegate(GetCompoundInterest));
                        break;
                    case "simple":
                        calculator = new InterestCalculator(money, interest, years, new CalculateInterestDelegate(GetSimpleInterest));
                        break;
                }

                Console.WriteLine("{0:F4}", calculator.GetInterest());
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var simpleInterest   = new InterestCalculator(2500, 7.2m, 15, GetSimpleInterest);
            var compoundInterest = new InterestCalculator(500, 5.6m, 10, GetCompoundInterest);

            Console.WriteLine("Compound Interest = {0}", compoundInterest);
            Console.WriteLine("Simple Interest = {0}", simpleInterest);
        }
        public static void Main()
        {
            InterestCalculator compoundInterest = new InterestCalculator(500m, 0.056m, 10, GetCompoundInterest);
            Console.WriteLine(compoundInterest.Balance);

            InterestCalculator simpleInterest = new InterestCalculator(2500m, 0.072m, 15, GetSimpleInterest);
            Console.WriteLine(simpleInterest.Balance);
        }
Пример #4
0
 static void Main(string[] args)
 {
     PerformCalculation simpleInterestCalc = GetSimpleInterest;
     PerformCalculation compelexInterestCalc = GetCompoundInterest;
     var simpleInterest = new InterestCalculator(2500, 0.072, 15, simpleInterestCalc);
     var complexInterest = new InterestCalculator(500, 0.056, 10, compelexInterestCalc);
     Console.WriteLine(simpleInterest);
     Console.WriteLine(complexInterest);
 }
        public static void Main()
        {
            InterestCalculator compoundInterest = new InterestCalculator(500m, 0.056m, 10, GetCompoundInterest);

            Console.WriteLine(compoundInterest.Balance);

            InterestCalculator simpleInterest = new InterestCalculator(2500m, 0.072m, 15, GetSimpleInterest);

            Console.WriteLine(simpleInterest.Balance);
        }
Пример #6
0
        static void Main(string[] args)
        {
            PerformCalculation simpleInterestCalc   = GetSimpleInterest;
            PerformCalculation compelexInterestCalc = GetCompoundInterest;
            var simpleInterest  = new InterestCalculator(2500, 0.072, 15, simpleInterestCalc);
            var complexInterest = new InterestCalculator(500, 0.056, 10, compelexInterestCalc);

            Console.WriteLine(simpleInterest);
            Console.WriteLine(complexInterest);
        }
        public void Test_GetSimpleInterestMethod()
        {
            // arrange
            decimal money = 2500m;
            decimal interest = 0.072m;
            int years = 15;
            decimal expected = 5200.0000m;
            InterestCalculator simpleInterest = new InterestCalculator(2500m, 0.072m, 15, InterestCalculatorMain.GetSimpleInterest);

            // assert
            decimal actual = simpleInterest.Balance;
            Assert.AreEqual(expected, actual, "Interest not calculated correctly");
        }
        public void Test_GetCompoundInterestMethod()
        {
            // arrange
            decimal money = 500m;
            decimal interest = 0.056m;
            int years = 10;
            decimal expected = 874.1968m;
            InterestCalculator compoundInterest = new InterestCalculator(500m, 0.056m, 10, InterestCalculatorMain.GetCompoundInterest);

            // assert
            decimal actual = compoundInterest.Balance;
            Assert.AreEqual(expected, actual, "Interest not calculated correctly");
        }
 public void Years_WhenYearsAreNegative_ShouldThrowArgumentOutOfRangeException()
 {
     InterestCalculator simpleInterest = new InterestCalculator(2500m, 0.072m, -15, InterestCalculatorMain.GetSimpleInterest);
 }
 public void Interest_WhenInterestIsNegative_ShouldThrowArgumentOutOfRangeException()
 {
     InterestCalculator compoundInterest = new InterestCalculator(500m, -0.056m, 10, InterestCalculatorMain.GetCompoundInterest);
 }
 public void InterestCalculator_WithAllArgumentsValid_ShouldPassTest()
 {
     InterestCalculator simpleInterest = new InterestCalculator(2500m, 0.072m, 8, InterestCalculatorMain.GetSimpleInterest);
 }