CalculateInterest() public method

public CalculateInterest ( int monthsCount ) : decimal
monthsCount int
return decimal
Example #1
0
        static void Main()
        {
            DepositAccount depositPersonAcc = new DepositAccount(Customer.Individual, 10000.00M, 2.5);

            Console.WriteLine("Individual deposit account(balance = {0}) interest for 12 months = {1:F2}."
                              , depositPersonAcc.Balance, depositPersonAcc.CalculateInterest(12));
            Console.WriteLine("Withdrawing from this account 9500.");
            depositPersonAcc.Withdraw(9500);
            Console.WriteLine("Individual deposit account(balance = {0}) interest for 12 months = {1:F2}."
                              , depositPersonAcc.Balance, depositPersonAcc.CalculateInterest(12));
            Console.WriteLine("Try to withdraw 501.");
            depositPersonAcc.Withdraw(501);

            LoanAccount loanPersonAcc  = new LoanAccount(Customer.Individual, -15250.35M, 2.0);
            LoanAccount loanCompanyAcc = new LoanAccount(Customer.Company, -50000, 1.5);

            Console.WriteLine("\nIndividual loan account(balance = {0}) interest for 3 months = {1:F2}."
                              , loanPersonAcc.Balance, loanPersonAcc.CalculateInterest(3));
            Console.WriteLine("Individual loan account(balance = {0}) interest for 10 months = {1:F2}."
                              , loanPersonAcc.Balance, loanPersonAcc.CalculateInterest(10));
            Console.WriteLine("Company loan account(balance = {0}) interest for 10 months = {1:F2}."
                              , loanCompanyAcc.Balance, loanCompanyAcc.CalculateInterest(10));
            Console.WriteLine("Company loan account(balance = {0}) interest for 2 months = {1:F2}."
                              , loanCompanyAcc.Balance, loanCompanyAcc.CalculateInterest(2));

            MortgageAccount mortgagePersonAcc  = new MortgageAccount(Customer.Individual, -2500.50M, 3.2);
            MortgageAccount mortgageCompanyAcc = new MortgageAccount(Customer.Company, -1000M, 1);

            Console.WriteLine("\nIndividual mortgage account(balance = {0}) interest for 6 months = {1:F2}."
                              , mortgagePersonAcc.Balance, mortgagePersonAcc.CalculateInterest(6));
            Console.WriteLine("Individual mortgage account(balance = {0}) interest for 10 months = {1:F2}."
                              , mortgagePersonAcc.Balance, mortgagePersonAcc.CalculateInterest(10));
            Console.WriteLine("Individual mortgage account(balance = {0}) interest for 12 months = {1:F2}."
                              , mortgageCompanyAcc.Balance, mortgageCompanyAcc.CalculateInterest(12)); //for first 12 months interest is 60$
            Console.WriteLine("Individual mortgage account(balance = {0}) interest for 24 months = {1:F2}."
                              , mortgageCompanyAcc.Balance, mortgageCompanyAcc.CalculateInterest(24)); //for 24 months interest is 60$ for first 12months + 120$ for next 12 months
        }
Example #2
0
        static void Main(string[] args)
        {
            var b = new Bank("ING");

            var c1 = new Individual();

            var d = new DepositAccount(b, c1, 1000, 3.85m, 12);

            Console.WriteLine(d.CalculateInterest());


            var l = new LoanAccount(b, c1, 1000, 3.5m, 12);

            Console.WriteLine(l.CalculateInterest());

            var c2 = new Company();
            var m  = new MortgageAccount(b, c2, 1500, 3.8m, 36);

            Console.WriteLine(m.CalculateInterest());
        }
Example #3
0
        public static void Main()
        {
            DepositAccount kiro = new DepositAccount(Customers.Individual, 1000m, 5);
            Console.WriteLine(kiro.CalculateInterest(10) + "\n");

            LoanAccount pesho = new LoanAccount(Customers.Individual, 1500m, 3);
            Console.WriteLine(pesho.CalculateInterest(12) + "\n");

            LoanAccount maglaOOD = new LoanAccount(Customers.Company, 1500m, 3);
            Console.WriteLine(maglaOOD.CalculateInterest(12) + "\n");

            MortgageAccount penka = new MortgageAccount(Customers.Individual, 50000m, 2);
            Console.WriteLine(penka.CalculateInterest(8) + "\n");

            MortgageAccount shadyAD = new MortgageAccount(Customers.Company, 250000m, 5);
            Console.WriteLine(penka.CalculateInterest(12) + "\n");

            MortgageAccount shadyOOD = new MortgageAccount(Customers.Company, 250000m, 5);
            Console.WriteLine(penka.CalculateInterest(24) + "\n");
        }