Answer to Question #323129 in C# for alpha

Question #323129

Write a program that accepts the amount of money deposited in a bank account, the annual interest rate and the target amount (The amount of money the account holder wants to have in the account after a period of time) and then calculates the number of years it will take for the money to accumulate to the targeted amount. NB: 1) The interest being earned is Compound Interest. 2) Don’t use the formula for calculating compound interest. For example if the money deposited is 10000 and the target amount is 20000 and the account earns an interest rate (compound) of 10% pa, then the output should be: - It will take 8 years for your money to reach your target. By the end of this period, the amount in your account will be 21435.89


1
Expert's answer
2022-04-04T16:12:15-0400
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter amount of money deposited in a bank account:");
            decimal moneyDeposite = decimal.Parse(Console.ReadLine());
            Console.Write("Enter annual interest rate:");
            decimal interestRate = decimal.Parse(Console.ReadLine());
            Console.Write("Enter target amount (The amount of money the account \nholder wants to have in the account after a period of time):");
            decimal targetAmount = decimal.Parse(Console.ReadLine());
            Calculate(moneyDeposite, targetAmount, interestRate);
            Console.ReadKey();
        }


        public static void Calculate(decimal moneyDeposited, decimal targetAmount,decimal interestRate)
        {
            int year;
            for (year = 0; moneyDeposited <= targetAmount; year++)
                moneyDeposited += moneyDeposited * (interestRate / 100m);


            Console.WriteLine($"It will take {year} years for your money to reach your target.");
            Console.WriteLine($"By the end of this period, the amount in your account will be {moneyDeposited}");
        }
    }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS