コード例 #1
0
        public static void Calculate()
        {
            decimal amount;

            Console.WriteLine("Kindly Enter Amount to be transferred");
            //get the amount to be transferred;
            try
            {
                amount = Convert.ToDecimal(Console.ReadLine());
                //compute service charge
                var charge = FeeHelper.computeExpectedCharge(amount);

                //Get the equivalent charge for the amount entered
                if (charge != null)
                {
                    Console.WriteLine($"Amount : {amount}");
                    Console.WriteLine($"Bank Charge:  {charge}");
                }
                else
                {
                    Console.WriteLine("Sorry we cannot process your transaction. Try to process another amount");
                    //proceed with any other information
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Enter a Valid Number");
            }
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            decimal amount;

            Console.WriteLine("Kindly Enter Amount to be transferred");
            //get the amount to be transferred;
            try
            {
                amount = Convert.ToDecimal(Console.ReadLine());
                //compute service charge
                var charge = FeeHelper.computeServiceCharge(amount);

                if (charge != null)
                {
                    var transferAmount = amount - Convert.ToDecimal(charge);
                    Console.WriteLine($"Amount : {amount}");
                    Console.WriteLine($"Transfer Amount: {transferAmount}");
                    Console.WriteLine($"Bank Charge:  {charge}");

                    Console.WriteLine($"Debit Amount: {transferAmount + FeeHelper.computeServiceCharge(transferAmount)}");
                    //proceed with other actions
                }
                else
                {
                    Console.WriteLine("Sorry we cannot process your transaction. Try to process another amount");
                    //proceed with any other information
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Enter a Valid Number");
            }
            Console.ReadKey();
        }