/// <inheritdoc />
        public async Task <Amount> CalcAmount(decimal initialValue, int months)
        {
            var compoundInterest = new CompoundInterest();
            var interestRate     = await GetInterestRate();

            var finalValue = compoundInterest.Calculate(new Amount(initialValue), interestRate, new Months(months));

            return(finalValue);
        }
Example #2
0
        static void Main(string[] args)
        {
            SimpleInterest oSI = new SimpleInterest(5000, 15.5, 3);

            oSI.Calculate();
            oSI.Display();
            oSI = null;

            CompoundInterest oCI = new CompoundInterest(5000, 15.5, 3, 4);

            oCI.Calculate();
            oCI.Display();


            oCI.DeductServiceCharge(250);
            oCI.Calculate();
            oCI.Display();
            oCI = null;



            Console.WriteLine("Press a key...");
        }
        public void Calculate_PrincipalAndPercentageAndYearsAndPeriods_ReturnTotalAmount()
        {
            var context = new CompoundInterestContext
            {
                Principal            = 1500.00,
                InterestPercent      = 4.3,
                InvestYears          = 6,
                CompoundingFrequency = 4,
            };

            double sum = CompoundInterest.Calculate(context);

            Assert.That(sum, Is.EqualTo(1938.84));
        }
        public void should_calculate_correctly_interest_value()
        {
            // Arr
            var compoundInterest = new CompoundInterest();
            var months           = new Months(5);
            var interestRate     = new InterestRate(0.01M);
            var amount           = new Amount(100.00M);

            // Act
            var finalAmount = compoundInterest.Calculate(amount, interestRate, months);

            // Ass
            finalAmount.Value.Should().Be(105.10M);
        }
        public void should_return_zero_value_if_amount_is_zero()
        {
            // Arr
            var compoundInterest = new CompoundInterest();
            var months           = new Months(5);
            var interestRate     = new InterestRate(0.01M);
            var amount           = new Amount(0.00M);

            // Act
            var finalAmount = compoundInterest.Calculate(amount, interestRate, months);

            // Ass
            finalAmount.Value.Should().Be(0);
        }
Example #6
0
        static void Main(string[] argd)
        {
            SimpleInterest   oSI = new SimpleInterest(5000, 12.5, 5);
            CompoundInterest oCI = new CompoundInterest(5000, 12.5, 5, 3);


            oSI.Calculate(); oCI.Calculate();
            CompareInterest compare = new CompareInterest();

            compare.Compare(oSI, oCI);

            Console.WriteLine();
            Console.WriteLine("Press any key");
            Console.ReadLine();
        }