Fee structure of students of different departments.
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.
#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;
}
Comments
Leave a comment