Create a class named as Recruitment which is derived from two base classes named as
Basic qualification and interview. Basic qualification contains the Name, marks in last
qualification, Interview class contains the marks obtained in interview. Recruitment class
will display the message as recruited or not recruited. Criteria for recruitment is if the
marks in last qualification is more than 80 and interview marks are greater than equal to 6
out of 10 for interview marks. Make sure that negative marks are not allowed.
#include <iostream>
#include <string>
#include <exception>
using namespace std;
class BasiQualification
{
public:
BasiQualification(string name_, int mark);
protected:
string name;
int markQual;
};
BasiQualification::BasiQualification(string name_, int mark) : name(name_)
{
if (mark < 0) throw ("ERROR: negative marks!");
markQual = mark;
}
class Interview
{
public:
Interview(int marks);
protected:
int markInter;
};
Interview::Interview(int marks)
{
if(marks < 0) throw ("ERROR: negative marks!");
markInter = marks;
}
class Recruitment : public Interview, BasiQualification
{
public:
Recruitment(string name_, int markB, int markI);
void Display();
};
Recruitment::Recruitment(string name_, int markB, int markI) : Interview(markI), BasiQualification(name_, markB)
{}
void Recruitment::Display()
{
if (markQual > 80 && markInter >= 6) cout << name << " is recruited!" << endl;
else cout << name << " is not recruited!" << endl;
}
int main()
try
{
Recruitment Bill("Bill", 100, 6);
Bill.Display();
Recruitment Mike("Mike", 50, 6);
Mike.Display();
Recruitment Jina("Jina", -10, 10);
Jina.Display();
return 0;
}
catch (const char* e)
{
cout << e << endl;
}
Comments
Leave a comment