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 string int int Variable name age weight bloodGroup string In the Donor class, define the following function. Method Description This method validates donor eligibility. Validate the donor bool validateDonor(Donordetails with the following conditions. donor) 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. Include This In Donor Class:- 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
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 string int int Variable name age weight bloodGroup string In the Donor class, define the following function. Method Description This method validates donor eligibility. Validate the donor bool validateDonor(Donordetails with the following conditions. donor) 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. Include This In Donor Class:- 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
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
Related questions
Question
QUESTION ATTACHED KINDLY SEE AND MATCH INPUT-OUTPUT AS IT IS.
ALSO, USE THE BELOW TEMPLATES WHILE MAKING A SOLUTION
---------TEMPLATES------------
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
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 6 images
Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education