Write a C++ program to check for the not-eligible donor by throwing a custom exception. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. The class Donor has the following protected variables.  Data Type Variable string name int age int weight string bloodGroup   In the Donor class, define the following function. Method Description bool validateDonor(Donor donor) This method validates donor eligibility. Validate the donor details with the following conditions. 1.Age must be greater than 30 then the donor is eligible. 2.If the age is less than 30 then throw an exception and check the weight should be greater than 44 kg in catch block, If the weight is also less than 44 then the donor is not eligible and rethrow the exception to the main method. If the weight is greater than 44 then the donor is eligible.   In the Main method, read the donor details from the user and create corresponding objects. Validate the donor to check the donor is eligible or not. Input and Output Format: Refer sample input and output for formatting specifications.  All text in bold corresponds to the input and the rest corresponds to output. Sample Input and Output 1: Enter donor details Enter the name John Enter the age 34 Enter the weight 46 Enter the blood group O+ve Donor is eligible   Sample Input and Output 2: Enter donor details Enter the name Daniel Enter the age 25 Enter the weight 50 Enter the blood group O+ve InvalidDonorException:Age is not valid Donor is eligible   Sample Input and Output 3: Enter donor details Enter the name Harry Enter the age 28 Enter the weight 42 Enter the blood group B+ve InvalidDonorException:Both age and weight is not valid Donor is not eligible   --------STRICTLY USE BELOW TEMPLATES ONLY WHILE MAKING SOLUTION-------- MAIN.CPP #include #include #include "Donor.cpp" using namespace std; int main() { //Fill your code here try { //Fill your code here } catch(const char* c) { //Fill your code here } return 0; }   DONOR.CPP #include #include using namespace std; class Donor{ protected: string name; int age; int weight; string bloodGroup; public: Donor(){} Donor(string name, int age, int weight,string bloodGroup) { this->name = name; this->age = age; this->weight = weight; this->bloodGroup = bloodGroup; } bool validateDonor(Donor donor) { //Fill your code here } };

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a C++ program to check for the not-eligible donor by throwing a custom exception.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.

The class Donor has the following protected variables. 

Data Type Variable
string name
int age
int weight
string bloodGroup

 

In the Donor class, define the following function.

Method Description
bool validateDonor(Donor donor)

This method validates donor eligibility. Validate the donor details with the following conditions.

1.Age must be greater than 30 then the donor is eligible.

2.If the age is less than 30 then throw an exception and check the weight should be greater than 44 kg in catch block,

If the weight is also less than 44 then the donor is not eligible and rethrow the exception to the main method.

If the weight is greater than 44 then the donor is eligible.

 

In the Main method, read the donor details from the user and create corresponding objects.
Validate the donor to check the donor is eligible or not.

Input and Output Format:
Refer sample input and output for formatting specifications. 
All text in bold corresponds to the input and the rest corresponds to output.


Sample Input and Output 1:

Enter donor details
Enter the name
John
Enter the age
34
Enter the weight
46
Enter the blood group
O+ve
Donor is eligible

 

Sample Input and Output 2:

Enter donor details
Enter the name
Daniel
Enter the age
25
Enter the weight
50
Enter the blood group
O+ve
InvalidDonorException:Age is not valid
Donor is eligible

 

Sample Input and Output 3:

Enter donor details
Enter the name
Harry
Enter the age
28
Enter the weight
42
Enter the blood group
B+ve
InvalidDonorException:Both age and weight is not valid
Donor is not eligible

 

--------STRICTLY USE BELOW TEMPLATES ONLY WHILE MAKING SOLUTION--------

MAIN.CPP

#include <iostream>
#include <sstream>
#include "Donor.cpp"
using namespace std;
int main()
{

//Fill your code here
try
{
//Fill your code here
}
catch(const char* c)
{
//Fill your code here
}
return 0;
}

 

DONOR.CPP

#include <iostream>
#include <sstream>
using namespace std;
class Donor{
protected:
string name;
int age;
int weight;
string bloodGroup;
public:
Donor(){}

Donor(string name, int age, int weight,string bloodGroup) {
this->name = name;
this->age = age;
this->weight = weight;
this->bloodGroup = bloodGroup;
}
bool validateDonor(Donor donor)
{
//Fill your code here
}
};
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education