Answer to Question #209962 in C++ for MUHAMMAD HAMDAN

Question #209962

Task is to create a class COVID with 6 private data members name, cnic, security code, age, address and blood pressure of patient. Class include public member functions

input ( ) function to input the attributes of patient

verify ( ) function to check security code provided at the time of registration

display ( ) function to display the patient cnic if security code is verified

show ( ) function to display the message NOT REGISTERED if security code doesn’t match Define verify function outside the class using scope resolution operator


1
Expert's answer
2021-06-23T17:07:21-0400


#include <iostream>
using namespace std;
class COVID{
    private:
        string name;
        string cnic;
        string security_code;
        int age;
        string sc="Hello";
        string address;
        int blood_pressure;
    public:
        void input() {
            cout<<"\nEnter name: ";
            cin>>name;
            cout<<"\nEnter cnic: ";
            cin>>cnic;
            cout<<"\nEnter security code: ";
            cin>>security_code;
            cout<<"\nEnter age: ";
            cin>>age;
            cout<<"\nEnter address: ";
            cin>>address;
            cout<<"\nEnter blood pressure: ";
            cin>>blood_pressure;
        }  
        string verify ( );
        void display ( ){
            string vr=verify();
            if (vr=="verified")
                cout<<"\ncnic: "<<cnic;
        }
        void show ( ) {
            string vr=verify();
            if (vr=="not verified")
                cout<<"\nNOT REGISTERED";
        }
};
string COVID::verify(){
    if (security_code==sc)
        return "verified";
    else
        return "not verified";
}
int main()
{
    COVID c;
    c.input();
    c.verify();
    c.display();
    c.show();
    


    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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS