static void Main(string[] args) { InterestDelegate interestDelegate = SimpleInterest; InterestDelegate interestDelegate1 = CompoundInterest; interestDelegate(); interestDelegate1(); }
static void Main(string[] args) { long sum = long.Parse(Console.ReadLine()); double interest = double.Parse(Console.ReadLine()); int years = int.Parse(Console.ReadLine()); InterestDelegate simpleDelegate = new InterestDelegate(GetSimpleInterest); InterestDelegate compoundDelegate = new InterestDelegate(GetCompoundInterest); double simple = StaticCalculator.Calculate(sum, interest, years, simpleDelegate); double compound = StaticCalculator.Calculate(sum, interest, years, compoundDelegate); Console.WriteLine("The simple interest is: {0:F4}", simple); Console.WriteLine("The compound interest is: {0:F4}", compound); }
public static double Calculate(long sum, double interest, int years, InterestDelegate customDelegate) { return customDelegate(sum, interest, years); }