Write c++ program to find efficiency of petrol engine, diesel engine and steam engine.
#include <iostream>
using namespace std;
class Regular{
float basic;
float DA;
float HRA;
float salary;
public:
Regular(float sal): basic(sal){
DA = 0.1 * basic;
HRA = 0.3 * basic;
salary = DA + HRA + basic;
}
float getSalary(){
return salary;
}
~Regular(){}
};
class Adhoc{
int number;
float wage;
public:
Adhoc(float wag): wage(wag){
}
void days(int n){
number = n;
}
float getSalary(){
return number * wage;
}
~Adhoc(){}
};
int main(){
Regular empl1(2000);
Adhoc empl2(200);
empl2.days(2);
cout<<"Salary of regular: "<<empl1.getSalary();
cout<<"\nSalary of adhoc: "<<empl2.getSalary();
return 0;
}
Comments
Leave a comment