Answer to Question #209927 in C++ for Maaz

Question #209927

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


1
Expert's answer
2021-06-23T05:21:42-0400
#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;
}

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