C++ Program to find simple interest

Q. WAP to find the simple interest. Take the interest rate as
R = 5% if T>7 yrs,
R = 10% if 7<=T<=12 yrs,
R = 15% if T>12 yrs.

#include <iostream.h>
#include <conio.h>
#include <iomanip.h> //IO manipulation header file

void main()
{
  float P,T,R,I;
  cout<<"Enter principle: ";
  cin>>P;
  cout<<"Enter time (year): ";
  cin>>T;
  if(T<7)
    R=5;
  else if(T>=7 && T<=12)
    R=10;
  else
    R=15;
  I=(P*T*R)/100;
  cout<<endl<<"Simple Interest = "<<I<<setw(5)<<"Ans";
  getch();
}


OUTPUT:

No comments:

Post a Comment