Answer to Question #213024 in C++ for Hemambar

Question #213024

Create a class named EB_amount. It has the data members units_used and bill. Use member function to set unit_used. Upto 200 units 3 rupees per unit, 201 to 500, 4 rupees per and above 500 5.5 rupees per unit are allotted by EB. Calculate the bill amount and display the amount. Create another class Salary with basic, DA and HRA. Set basic by a member function. 104 percent of basic is assigned as DA and 10 percent is allotted as HRA. Display the total salary. Derive a class Budget contains income, tuition_fee, house_rent, saving, grocery, eb_bill as data members. Set the values and get the values of income and eb_bill from parent classes. Display the budget details. 




1
Expert's answer
2021-07-11T14:38:56-0400

class EB_amount

{

private:

int units_used;

int bill;

public:

int set_units_used(int units_used)

{

this->units_used = units_used;

if (this->units_used <= 200) bill = 3 * this->units_used;

else if (this->units_used >= 20 && this->units_used < 500) bill = 4 * this->units_used;

else bill = 5, 5 * this->units_used;

std::cout << "The amount: " << bill<<endl;

return bill;

}

};

class Salary

{

private:

int basic;

int DA;

int HRA;

public:

int set_basic(int basic)

{

this->basic = basic;

DA = (basic / 100) * 104;

HRA = (basic / 100) * 10;

std::cout << "The total salary: " <<this->basic+DA-HRA<<endl;

return this->basic + DA - HRA;

}


};

class Budget: private EB_amount, Salary

{

private:

int income;

int tuition_fee;

int house_rent;

int saving;

int grocery;

int eb_bill;

public:

Budget(int basic,int tuition_fee, int house_rent, int saving, int grocery, int units)

{

income = Salary().set_basic(basic);

this->tuition_fee=tuition_fee;

this->house_rent=house_rent;

this->saving=saving;

this->grocery=grocery;

std::cout << "The tuition fee: " << this->tuition_fee << endl;

std::cout << "The house rent: " << this->house_rent << endl;

std::cout << "The saving: " << this->saving << endl;

std::cout << "The grocery: " << this->grocery << endl;

eb_bill = EB_amount().set_units_used(units);

}

};



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
APPROVED BY CLIENTS