Answer to Question #276840 in C++ for hari

Question #276840

Create a class “patient” with data members Patient_id and Oxygen_level.

 

    Create another class “covid” with character data member “test” (this can take value either ’p’ or ‘n’). Data members of both the classes should be initialized using constructor.


Class “oxygen_supply” is inherited from both the above classes. Include member function eligibility_supply which checks whether a patient needs oxygen supply or not.

 

If the patient has tested to positive(‘p’) and Oxygen_level is below 90, then print “patient needs oxygen supply”.

If the patient has tested to negative(‘n’) and Oxygen_level is below 90, then print “patient needs oxygen supply”. 



1
Expert's answer
2021-12-07T20:58:30-0500
#include <iostream> 
using namespace std;
const int LEN = 80; 
class Patient 
{ 
      public: 
                       char Patient_id[LEN]; 
                       char Oxygen_level; 
      public: 
 
                    void getdata() 
                     { 
                          cout<<"\nEnter Patient ID : "; 
                          cin>>Patient_id; 
                          cout<<"\nEnter Patient Oxygen level : "; 
                          cin>>Oxygen_level; 
                      } 
                      
                     void showdata() 
                      { 
                           cout<<"\nPatient ID : "<<Patient_id; 
                           cout<<"\nOxygen Level : "<<Oxygen_level; 
                       } 
}; 
class Covid
{ 
       public: 
                            char test ; 
       public: 
                      void getdata() 
                       { 
                            cout<<"\nEnter Test result (Use p for positive and n for negavive) : "; 
                            cin>>test; 
                        } 
                      void showdata() 
                       { 
                            cout<<"\nTest result is : "<<test; 
                        } 
}; 
class Amount 
{ 
        private: 
                              int dues; 
                             
        public: 
                        void getdata() 
                          { 
                             
                               cout<<"Enter Dues of Patient : "; 
                               cin>>dues; 
                           } 
                         void showdata() 
                           { 
                          
                          
                               cout<<"\nTotal Dues of Patient : "<<dues; 
                            } 
}; 


class Oxygen_supply: public Patient, public Covid
{
	public:
	void oxygen_eligibility()
	{
		if(test == 'p'  && Oxygen_level<90 ){
			cout<<"Patient needs oxygen";
		}
		else {
			cout<<"Patient needs oxygen";
		}
	}
	
};
   int main() 
       { 
                  Patient p1; 
                  cout<<"\nEnter Data "; 
                  p1.getdata(); 
                  cout<<"\nInserted Data is : \n"; 
                  p1.showdata();  
				  p1.oxygen_eligibility(); 
                 return 0; 
        }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment