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
#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;
}
Comments
Leave a comment