by Dinesh Thakur Category: Classes in C++

 

# 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



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles