Suppose you are a programmer in Agha Khan Hospital. Agha Khan Hospital Chairman has assigned a task you
to develop an application in regards to handle the data related to COVID-19 Vaccination Registration. Each
patient is provided with a security code needed for verification at the time of vaccination. Range of security
code is 1 to 10.
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
1. input ( ) function to input the attributes of patient
2. verify ( ) function to check security code provided at the time of registration
3. display ( ) function to display the patient cnic if security code is verified
4. 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>
#include <string>
#include <time.h>
using namespace std;
class COVID{
string name, address;
int cnic, seccode, age;
float bpressure;
public:
COVID(){}
void input(){
cout<<"Input name: "; cin>>name;
cout<<"Input address: "; cin>>address;
cout<<"Input CNIC: "; cin>>cnic;
cout<<"Input age: "; cin>>age;
cout<<"Input blood pressure: "; cin>>bpressure;
srand(time(NULL));
seccode = rand() % 10 + 1;
cout<<"Your security code is: "<<seccode;
}
bool verify();
void display(){
if(verify()) cout<<"\nCNIC: "<<cnic;
else show();
}
void show(){
cout<<"\nNOT REGISTERED";
}
};
bool COVID::verify(){
cout<<"\nInput security code: ";
int x;
cin>>x;
if(x == seccode) return true;
return false;
}
Comments
Leave a comment