Tuesday, 3 March 2015

//Write a program to calculate compound interest.
using System;
class a
{
        public void interest(double p ,double r,double n ,double t)
        {
                double tot=0;
               for(int i=1;i<t+1;i++)
               {
                        tot=p*Math.Pow((1+r/n),(n*i));
                        Console.WriteLine("your total for year {0} "+" is {1:F0}",i,tot);
               }
        }
}
class my
{
        public static void Main()
        {
                Double p,r,n,t;
                Console.Write("Enter Pricipal Amount:");
                p=Convert.ToDouble(Console.ReadLine());
                Console.Write("Enter Rate:");
                r=Convert.ToDouble(Console.ReadLine())/100;
                Console.Write("No of year:");
                n=Convert.ToDouble(Console.ReadLine());
                Console.Write("No of years");
                t=Convert.ToDouble(Console.ReadLine());
                a a1= new a();
                a1.interest(p,r,n,t);
                Console.Read();
        }
}

No comments:

Post a Comment