C++ Program to Find Interest





Constructor can be defined as the member function, which has the same name of the class. the object created by the constructor is destroyed with the help of destructor.

This is a program to find the interest using constructor.

#include<iostream.h>

#include<conio.h>

Class interest

{

Private:

Float principle, time, rate, interest;

Public:

Interest ();

Interest (float, float, float);

Void display ();

};

Interest:: interest ()

{

Interest =0;

Principle = 0;

Time=0;

Rate=0;

}

Interest:: Interests (float p, float t, float r)

{

Principle=p;

Time=t;

Rate=r;

Interest=0;

}

Void interest:: display ()

{

Interest = (principle * time * rate) /100;

Cout<<”\n interest=”<<interest;

}

Void main ()

{

Float p, t, r;

Cout<<”\n enter the principle, time, rate”;

Cin>>p>>t>>r;

Interest obj (p, t, r);

Obj.dispay ();

getch ();

}



Related posts:

  1. C++ Program Using Constructor and Destructor This is an object oriented programming in c++ to create...
  2. C++ Program to Find Sum and Average Using Class Class is the expanded concept of data structure, instead of...
  3. C++ Program Using Friend Function Friend function is used to access private, public and protected...
  4. C++ Program Using getdata() and display() The program uses member function getdata() and display() in-order to...
  5. C++ Program showing assignment operator overloading The symbol ‘=’ is used as Assignment operators. It is...