Question

Please answer the following in commented C++ code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

#include<iostream>

#include<cstdio>

using namespace std;

class Patient{

private:

long patientID;

string name;

char gender;

string birthDate;

public:

Patient(long id, string name, char gender, string date){

this->patientID = id;

this->name = name;

this->gender = gender;

this->birthDate = date;

}

void printdata(){

printf("%-10ld %-20s %-13s %-5c\n",patientID,name.c_str(), birthDate.c_str(), gender);

}

};

int main(){

Patient *p1 = new Patient(10023,"Joe Garcia", 'M', "11/10/1979");

Patient *p2 = new Patient(10024, "Suzy Walter", 'F', "01/01/2010");

Patient *p3 = new Patient(10025, "Amelia Perez", 'F', "12/05/1983");

Patient *p4 = new Patient(10026, "Tim Ducrest", 'M', "01/12/2000");

Patient *patient[4] = {p1,p2,p3,p4};

printf("%-10s %-20s %-13s %-9s\n", "ID", "Name", "Birth Date", "Gender");

for(int i=0;i<50;i++)

cout<<"-";

cout<<"\n";

p1->printdata();

p2->printdata();

p3->printdata();

p4->printdata();

return 0;

}

output:

ID Name Birth Date Gender 10023 10024 10025 10026 Joe Garcia Suzy Walter Amelia Perez Tim Ducrest 11/10/1979M 01/01/2010 12/0

Add a comment
Know the answer?
Add Answer to:
Please answer the following in commented C++ code. The purpose of this problem is to practice...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT