10 Mar 2013

compound_interest

/*

program to compute compound interest...

*/ 

#include<iostream.h>
#include<conio.h>
#include<math.h>
 

void main()
 

{
 

float a,b,c,d,f,g;
int e;
 

clrscr();
 

cout<<"Enter your principal amount:"<<endl;
cin>>a;
cout<<"Enter the rate of interest:"<<endl;
cin>>b;
cout<<"Enter the time period:"<<endl;
cin>>c;
cout<<"Enter your choice:"<<endl;
cout<<"1.Simple Interest"<<endl<<"2.Compound Interest"<<endl;
cin>>e;
switch(e)
{
case 1: d=(a*b*c)/100;
         cout<<"Interest is:"<<d<<endl;
         cout<<"Amount is:"<<(a+d)<<endl;
         break;

case 2: g=b/100;
          f=a*pow((1+g),c);
          cout<<"Interest is:"<<(f-a)<<endl;
          cout<<"Amount is:"<<f<<endl;
          break;

}
if(e>2)
cout<<"Invalid input";
 

getch();
}

Categories: , ,

0 comments:

Post a Comment

Copyright © UPgradeCODING | Powered by Blogger