Answer to Question #206065 in C++ for Ahmad

Question #206065

Write a class Fee having the following attributes and behavior

 No.of Students

 Fee_per_Student

 Float fee

Pure virtual fun ctions:

 Monthly_fee()

 display()

Derived the following classes from the base class Fee:

 CS

 Chemistry

 BBA

Perform the functionality:-

 Calculate the monthly fee for every department.

 Show the results on the console using Display () function.

 Write destructor when you realize that this is the end of program.

 Use virtual destructor concept in the above hierarchy.

Note:

 Use virtual Member functions for derived classes.

 Use appropriate values for per number of students in departments.

 User appropriate data types.


1
Expert's answer
2021-06-11T14:11:55-0400


#include <iostream>


using namespace std;
class Fee{
    protected:
        int no_of_stds;
        int fee_per_std;
        float fee;
    public:
        virtual void Monthly_fee()=0;
        virtual void display()=0;
};


class CS: public Fee{
    int no_of_stdsCs;
    void display(){
        cout<<"Total fee in CS department is "<<no_of_stdsCs*fee;
    }
    ~CS(){
        
    }
};
class Chemistry: public Fee{
    int no_of_stdsChem;
    void display(){
        cout<<"Total fee in Chemistry department is "<<no_of_stdsChem*fee;
    }
    ~Chemistry(){
        
    }
};
class BBA: public Fee{
    int no_of_stdsbba;
    void display(){
        cout<<"Total fee in BBA department is "<<no_of_stdsbba*fee;
    }
    ~BBA(){
        
    }
};
int main()
{


    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