Sunday, December 7, 2014

Write a C++ program using class to calculate simple interest amount use default value for rate.

# include
# include
class bank
{
private:
float p;
float r;
float t;
float si;
float amount;
public:
void read ( )
{
cout <<" Principle Amount : ";
cin>>p ;
cout<<" Rate of Interest : ";
cin>>r;
cout <<" Number of years : ";
cin>>t;
si= (p *r*t) /100;
amount = si + p;
}
void show( )
{
cout<<"\n Principle Amount: "<<p;
cout <<"\n Rate of Interest: "<<r;
cout <<"\n Number of years: "<<t;
cout <<"\n Interest : "<<si;
cout <<"\n Total Amount : "<<amount;
}
};
void main ( )
{
clrscr ( );
bank b ;
b.read ( );
b.show ( );
getch();
}

1 comment: