Answer to Question #256015 in C# for Umar farouk

Question #256015
Financial application: compound value) Suppose you save $100 each month into a savings account with the annual interest rate 5%. Thus, the monthly interest rate is After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252 After the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417) = 302.507 and so on. Write a program that prompts the user to enter a monthly saving amount and displays the account value after the sixth month. (In Exercise 4.30, you will use a loop to simplify the code and display the account value for any month.
1
Expert's answer
2021-10-29T01:49:43-0400
using System;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Console.Write("Input a monthly saving amount:");
                string str = Console.ReadLine();
                double amountSaving = float.Parse(str);


                const double rate = 0.00417f;
                int qtyMonth = 6;
                double account = 0;


                for (int i = 1; i <= qtyMonth; i++)
                {
                    account = (amountSaving + account) * (1 + rate);
                    account = Math.Truncate(account * 1000) / 1000;   // round by 3 digits
                    Console.WriteLine("Account value after the {0} month: {1:F3}", i, account);
                }
            }
            catch
            {
                Console.WriteLine("Bad amount");
                return;
            }
        }
    }
}

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
APPROVED BY CLIENTS