Tuesday 2 October 2018

Calculating the simple interest and amount in C++

Simple Interest

An increase in value(or amount) of money over a period of time is called simple interest. The value or amount increases when money is loaned or deposited.

Mathematically,
                           Simple Interest = P * T * R
                                                       100
Where,
            Principal(P)=The actual amount of money loaned or deposited.
            Time(T)=The duration for which the money is loaned or deposited(annually or biannually).
            Rate(R)=The rate of increase in money loaned or deposited(taken in %).       
            Simple Interest(SI)=The increase in amount of money by depositing or loaning the principal.                                               
                            A=P+SI
Where,
            Amount(A)=The total amount at end of the time period(T), which is the sum of principal(P) and simple interest(SI).


Write a program in C++ to input the principal, time, rate and calculate the simple interest and amount.

    

In this program, we simply input the principal, time, and rate from the user. With the help of these parameters, and formulas we calculate the simple interest and amount.


Program


#include<iostream.h>
#include<conio.h>
void main()
{
long int p;
long double r,si,amt;
int t;
clrscr();
cout<<"Enter the Principal amount= ";
cin>>p;
cout<<"Enter the annual Rate= ";
cin>>r;
cout<<"Enter the Time(in years)= ";
cin>>t;
si=((p*t*r)/100);
amt=p+si;
cout<<endl<<"Your Simple Intrest is= "<<si;
cout<<endl<<"Your total amount after "<<t<<" year/s= "<<amt;
getch();
}



Output



Program to calculate simple interest and amount
CALCULATING THE SIMPLE INTEREST AND AMOUNT









Explanation


In the above program, the input of principal(P), rate(R), and time(T) are 5000, 4.5, and 3 respectively.
So,
SI5000*4.5*3 = 675
             100

A=P+SI=5000+675=5675

In this way, we obtain the simple interest and amount. Then it is displayed on the screen.




No comments:

Post a Comment