Answer to Question #201119 in C++ for Ammar

Question #201119

Implement a program in C++ to define a class MONTHLY_EXPENSE. Declare two data members i.e. household expense and education expense in it. 

• Calculate total expense of June and display using member function. 

• Calculate total expense of July and display using member function. 

• Calculate total expense of two months (objects) i.e. June and July, and display it using member function. 

• Also compare total expense of two months (objects) i.e. June and July.


1
Expert's answer
2021-05-31T23:54:39-0400
#import <iostream>

class MonthlyExpence {
private:
    double household;
    double education;
    
    double totalJuneExpence() {
        // logic of the function
    }
    double totalJulyExpence() {
        // logic of the function
    }
    double totalJuneJulyExpence() {
        return this->totalJuneExpence() + this->totalJulyExpence();
    }
public:
    MonthlyExpence(double household, double education) {
        this->household = household;
        this->education = education;
    }
    void displayJuneExpence() {
        std::cout << "Total expence for June : " << this->totalJuneExpence();
    }
    void displayJulyExpence() {
        std::cout << "Total expence for July : " << this->totalJulyExpence();
    }
    void displayJuneJulyExpence() {
        std::cout << "Total expence for June and July : " << this->totalJuneJulyExpence();
    }
    bool compareJuneJulyExpence(double june, double july) {
        return june > july;
    }
};

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