Find Simple Interest using C++
Write a Program in C++ to find Simple
Interest.
#include <iostream.h>
#include <conio.h>
class
SI
{
public:
double p,t,r;
void interest(double,double,double);
};
void
SI :: interest(double a, double b, double c)
{
double i,sum;
p=a;
t=b;
r=c;
i=(p*t*r)/100;
sum=p+i;
cout<<"\nThe Interest is: "<<i;
cout<<"\nThe Sum is: "<<sum;
getch();
}
int
main()
{
double principal,time,rate;
clrscr();
cout<<"Principal: ";
cin>>principal;
cout<<"Time: ";
cin>>time;
cout<<"Rate: ";
cin>>rate;
SI
ob;
ob.interest(principal,time,rate);
return 0;
}
Output:
Principal: 5000
Time:10
Rate: 10
The Interest is: 5000
The Sum is: 10000
Comments
Post a Comment