Resources » Code Snippets » C# Syntax

Program to calculate compound interest and total amount


Last Updated:   Category: C# Syntax    
Author: Member Level: Silver    Points: 10



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);
}
}
}
}


Did you like this resource? Share it with your friends and show your love!

Responses to "Program to calculate compound interest and total amount"
Feedbacks      

Post Comment:




  • 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:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Priya jain
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India