Tuesday, 21 February 2012

simple intrest programme by using multilevel inheritence in c++



/*Count simple intrest by using multilevel inheritence in c++*/
#include<iostream>
using namespace std;
  class base
     {
       public:
         int prin,no;         //value of  principal and time
       public:
         void Data();
     };
   void base::data()
      {
      cout<<"-------------------------------------------------------\n";
       cout<<"enter the value of principal and time=>";
       cin>>p>>n;
     }

class Derived1: public base
     {
       public:
        int rate;         //rate of interest
       void data();
     };
  void derived1::data()
     {
       base::data();
       cout<<"enter the value of rate of interest=>";
       cin>>r;
       float si=prin*no*rate/100;
      cout<<"\nsimple interest is=>";
       cout<<si<<"\n---------------------------------------------------------\n";
     }
   class Derived2: public Derived1
    {
      public:
      void Display()
        {
          Derived1::data();
         }
  };
int main()
{
class Derived2 a;
a.Display();
}//end of main

No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}