C# Program to Calculate simple interest

Formula to calculate simple interest

C# program to calculate simple interest has been shown here. Simple interest is the amount of interest which is calculated based on the initial principal, interest rate and time (in years). It is determined by using following formula:


$SI = {\Large \frac{p * r * t}{100}}$


Here $SI$ represents simple interest. Pricipal amount, annual interest rate and time have been represented by $p$, $r$ and $t$ respectively. As an example, let's assume $p = 1000$, $r = 5$ and $t = 2$ then by using above formula, we get the value of simple interst $SI = 100$.






1. Program & output to calculate simple interest

Code has been copied
/***********************************************
            alphabetacoder.com
    C# program to compute simple interest 
***********************************************/

using System;

namespace SimpleInterest
{
    class Program
    {
        static void Main(string[] args)
        {
            //declare variables
            double p,r,t,si;
            
            //take input of principal, interest rate and time
            Console.Write("Enter principal amount= ");
            p = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter interest rate= ");
            r = Convert.ToDouble(Console.ReadLine());
            Console.Write("Enter time= ");
            t = Convert.ToDouble(Console.ReadLine());
            
            //calculate simple interest
            si=p*r*t/100;
            
            //print result
            Console.Write("Simple interest= "+si+"\n");
            
            // wait for user to press any key
            Console.ReadKey();
        }
    }
}

Output


Enter principal amount= 5000

Enter interest rate= 3.5

Enter time= 5

Simple interest= 875