Given a problem and program, fill up the blank spaces in the program in order to make the program work correctly. --------------------------------------------------------------- Health Center hospital has a registration form for the patients to register their details. Exceptions should be handled when the patient enters his/her details, because the users may enter invalid details into the form(For example age should have only positive values). Implement this concept by using Exception handling in c++. The class named Register with the following constructor and methods. Constructor Description Register(string name,int age,string gender,int height,int weight) Set the values passed as parameters. void display() This method displays patient's name,age,gender,height,weight.   Input and Output Format : Refer sample input and output for formatting specifications. All text in bold corresponds to input and the rest corresponds to output. Sample Input and Output: Enter your name Nivya Enter your age -21 Exception: Age should be positive Enter your age again 21 Enter your gender Female Enter your height(in centimeters) 156 Enter your weight(in kilograms) -48 Exception: Weight should be positive Enter your weight(in kilograms) again 48 Name : Nivya Age : 21 Gender : Female Height : 156 cm Weight : 48 kg   ----------- PLACE TO FILLUP IN BELOW PROGRAM AT LINE NUMBER 43 , 60 , 75 ----------------------------------------- 1 #include  2 #include  3 #include   4 #include   5 using namespace std;  6 class Register {  7    public:  8       string name,gender;  9       int age,weight,height;  10    public:  11 Register()  12 {  13 }  14       Register(string name,int age,string gender,int height,int weight)  15       {  16      this->name = name;  17          this->age = age;  18      this->gender = gender;  19          this->height = height;  20          this->weight = weight;  21       }  22    public:  23      virtual void display()  24       {  25          cout <<"Name : "<>name;  39       try  40      {  41       cout <<"Enter your age"<>age;  43       if(___________)  44     {  45         throw "Exception: Age should be positive";  46     }  47           }  48       catch(const char* msg)  49        {  50      cerr << msg << endl;  51       cout <<"Enter your age again"<>age;  53         }  54       cout <<"Enter your gender"<>gender;  56       try  57      {  58       cout <<"Enter your height(in centimeters)"<>height;  60       if( __________ )  61     {  62         throw "Exception: Height should be positive";  63     }  64           }  65       catch(const char* msg)  66        {  67      cerr << msg << endl;  68       cout <<"Enter your height(in centimeters) again"<>height;  70         }  71       try  72      {  73       cout <<"Enter your weight(in kilograms)"<>weight;  75       if( __________________)  76     {  77         throw "Exception: Weight should be positive";  78     }  79           }  80       catch(const char* msg)  81        {  82      cerr << msg << endl;  83       cout <<"Enter your weight(in kilograms) again"<>weight;  85         }  86       Register r(name,age,gender,height,weight);  87        r.display();  88    return 0;  89 }

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
100%

Given a problem and program, fill up the blank spaces in the program in order to make the program work correctly.

---------------------------------------------------------------

Health Center hospital has a registration form for the patients to register their details. Exceptions should be handled when the patient enters his/her details, because the users may enter invalid details into the form(For example age should have only positive values). Implement this concept by using Exception handling in c++.

The class named Register with the following constructor and methods.

Constructor Description
Register(string name,int age,string gender,int height,int weight) Set the values passed as parameters.
void display() This method displays patient's name,age,gender,height,weight.

 

Input and Output Format :

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

Sample Input and Output:

Enter your name
Nivya
Enter your age
-21
Exception: Age should be positive
Enter your age again
21
Enter your gender
Female
Enter your height(in centimeters)
156
Enter your weight(in kilograms)
-48
Exception: Weight should be positive
Enter your weight(in kilograms) again
48
Name : Nivya
Age : 21
Gender : Female
Height : 156 cm
Weight : 48 kg

 

----------- PLACE TO FILLUP IN BELOW PROGRAM AT LINE NUMBER 43 , 60 , 75 -----------------------------------------

1 #include<iostream> 
2 #include<cmath> 
3 #include <iomanip> 
4 #include <cstring> 
5 using namespace std; 
6 class Register { 
7    public: 
8       string name,gender; 
9       int age,weight,height; 
10    public: 
11 Register() 
12 { 
13 } 
14       Register(string name,int age,string gender,int height,int weight) 
15       { 
16      this->name = name; 
17          this->age = age; 
18      this->gender = gender; 
19          this->height = height; 
20          this->weight = weight; 
21       } 
22    public: 
23      virtual void display() 
24       { 
25          cout <<"Name : "<<name<<endl; 
26      cout <<"Age : "<<age<<endl; 
27      cout <<"Gender : "<<gender<<endl; 
28      cout <<"Height : "<<height<<" cm"<<endl; 
29      cout <<"Weight : "<<weight<<" kg"<<endl; 
30       } 
31 }; 
32 // Main function for the program 
33 int main( ) 
34 { 
35       string name,gender; 
36       int age,weight,height; 
37       cout <<"Enter your name"<<endl; 
38       cin>>name; 
39       try 
40      { 
41       cout <<"Enter your age"<<endl; 
42       cin>>age; 


43       if(___________) 


44     { 
45         throw "Exception: Age should be positive"; 
46     } 
47           } 
48       catch(const char* msg) 
49        { 
50      cerr << msg << endl; 
51       cout <<"Enter your age again"<<endl; 
52       cin>>age; 
53         } 
54       cout <<"Enter your gender"<<endl; 
55       cin>>gender; 
56       try 
57      { 
58       cout <<"Enter your height(in centimeters)"<<endl; 
59       cin>>height; 


60       if( __________ ) 


61     { 
62         throw "Exception: Height should be positive"; 
63     } 
64           } 
65       catch(const char* msg) 
66        { 
67      cerr << msg << endl; 
68       cout <<"Enter your height(in centimeters) again"<<endl; 
69       cin>>height; 
70         } 
71       try 
72      { 
73       cout <<"Enter your weight(in kilograms)"<<endl; 
74       cin>>weight; 


75       if( __________________) 


76     { 
77         throw "Exception: Weight should be positive"; 
78     } 
79           } 
80       catch(const char* msg) 
81        { 
82      cerr << msg << endl; 
83       cout <<"Enter your weight(in kilograms) again"<<endl; 
84       cin>>weight; 
85         } 
86       Register r(name,age,gender,height,weight); 
87        r.display(); 
88    return 0; 
89 } 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
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