Answer to Question #284287 in C++ for Raju

Question #284287

Write c++ program to find efficiency of petrol engine, diesel engine and steam engine.


1
Expert's answer
2022-01-03T04:27:52-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog