Пример #1
0
        static void Main()
        {
            Console.WriteLine("'Money' 'Interest' 'Years' 'Type' with spaces as separator:");

            while (true)
            {
                string[] commandargs = Console.ReadLine().Split(' ');
                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());
            }
        }
        static void Main()
        {
            InterestCalculator simpleInterest = new InterestCalculator(2500m, 7.2, 15, GetSimpleInterest);

            Console.WriteLine(simpleInterest.NewSum);

            InterestCalculator compoundInterest = new InterestCalculator(500m, 5.6, 10, GetCompoundInterest);

            Console.WriteLine(compoundInterest.NewSum);
        }