# Program to calculate compound interest and total amount

This program is based on do-while loop by using C#, useful for bank.

Explanation:

If the user want to calculate compound interest and total amount
at the end of the period this program is useful.
User will ask to enter the principle amount, rate of interest and period.
After entering the values user will get calculated compound interest
and total amount.
If user wants to continue for another amount, user can!

Program:

using System;
using System.Text;

namespace BANK
{
class Program
{
static void Main(string[] args)
{
string a;
Console.WriteLine("...Wel-Come To Recurring Deposite Account...");
Console.WriteLine("");
try
{
do
{
uint amt, i, amt1, month;
double interest, result = 0, rate;
Console.WriteLine("Enter the amount");
amt = Convert.ToUInt32(Console.ReadLine());
Console.WriteLine("Enter the rate");
rate = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter no. of months");
month = Convert.ToUInt32(Console.ReadLine());
amt1 = amt;
for (i = 0; i < month; i++)
{
interest = amt * rate / 1200;
result = result + interest;
amt = amt + amt1;

}

Console.WriteLine("Total Interest is :{0}", result);
Console.WriteLine("Total CAPITAL is :{0}", (amt - amt1));
Console.WriteLine("Total AMOUNT is :{0}", (amt - amt1 + result));
Console.WriteLine("");
Console.WriteLine("Do you want to continue? [YES / NO]");
a = Console.ReadLine();
Console.WriteLine("");

}
while (a != "NO" || a != "no");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}

### Comments

• Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
• No HTML formatting and links to other web sites are allowed.
• This is a strictly moderated site. Absolutely no spam allowed.
• Name:
Email:
Return to Article Index