define inline function to calculate simple interest and compound interest.Write a c++ program to compute simple interest and compound interest for the given p,n and r values
Answers
Answer:
# include <iostream.h>
# include <conio.h>
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();
}
Class Using Private Keyword
You’ll also like:
Write a java program to calculate the simple and compound interest using Scanner class.
C Program Write a Program to Calculate Interest of Value
C Program Calculate Sum of Diagonal Elements of a Matrix
C Program Write a Program to Find the Compound Interest
Write A C++ Program To Illustrate The Concept Of Public Keyword.