Parameterized Constructor

in Hindi - Parameterized Constructor



not yet

Source Code :

RUN#include <iostream.h>
#include <conio.h>

class loan{
    
private:
float principle,no_of_years,rate_of_interest,simple_interest;

public:
loan(float x ,float y, float z=13.5)
{
principle=x;
no_of_years=y;
rate_of_interest=z;
}
void cal()
{
simple_interest=(principle*no_of_years*rate_of_interest)/100;
}
void display()
{
cout<<"Principle :"<<principle<<endl;
cout<<"Rate of interest :"<<rate_of_interest<<endl;
cout<<"No. of years :"<<no_of_years<<endl;
cout<<"Simple interest :"<<simple_interest<<endl;
}
};
int main(){
loan l1(9000.0,3);
l1.cal();
l1.display();

loan l2(8000.0,3,11.0);
l2.cal();
l2.display();

return 0;
}