Professional Documents
Culture Documents
C++week5 1
C++week5 1
>>write a c++ program to calculate net income of the employee given ba,hra,it,basic using function
overloading.
>>calculate the simple interest using function overloading,given principle,rate of interest and time.
//1.
#include<iostream>
int main(){
area_of_rectangle(2,3);
area_of_rectangle(2.5,4.5);
return 0;
#2.
#include<iostream>
class Employee{
private:
float basic,da,hra,it,n;
public:
Employee(){
cin>>basic;
Employee(float b){
basic=b;
void display(){
da=basic*20/100;
hra=basic*5/100;
it=basic*2/100;
n=basic+da+hra-it;
cout<<"\n"<<"Net salary:"<<n;
};
int main(){
Employee obj;
obj.display();
Employee o(10000);
o.display();
#Output:
#3.
#include<iostream>
class Employee{
private:
float basic,da,hra,it,n;
public:
void Salary(){
cin>>basic;
}
void Salary(float b){
basic=b;
void display(){
da=basic*20/100;
hra=basic*5/100;
it=basic*2/100;
n=basic+da+hra-it;
cout<<"\n"<<"Net salary:"<<n;
};
int main(){
Employee obj;
obj.Salary();
obj.display();
Employee o;
o.Salary(10000);
o.display();
#output:
#4.
#include<iostream>
class Interest{
private:
float si,p,t,r;
public:
Interest(){
cin>>p;
cin>>t;
cin>>r;
cout<<endl<<"Simple Interest is:"<<(p*t*r)/100;
p=pr;
t=time;
r=rate;
};
int main(){
Interest obj1;
Interest obj2(10000,5,2);
#output
#6.
#include<iostream>
class Interest{
private:
float si,p,t,r;
public:
SimpleInterest(){
cin>>p;
cin>>t;
cin>>r;
p=pr;
t=time;
r=rate;
};
int main(){
Interest obj1;
obj1.SimpleInterest();
Interest obj2;
obj2.SimpleInterest(10000,5,2);
return 0;
#output:
ssss